繁体   English   中英

撤消“git remote rm origin”

[英]Undo “git remote rm origin”

我在执行git push时遇到了这个错误:

fatal: could not read Username for 'https://usts.visualstudio.com': No such file or directory

看起来我在这里提到的git 1.8.5中遇到了一个错误: https//stackoverflow.com/a/20884273/45603

谷歌带我到这篇文章: https//stackoverflow.com/a/20871910/45603

所以,我运行了git remote rm origin然后是git remote add origin 'git@github.com:username/repo.git'

现在,每当我执行git push时,我都会收到以下消息:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

我想撤消git remote rm origin并回滚到git 1.8.4。

如何撤消git remote rm origin

编辑:运行git push --set-upstream origin master (由git建议)给出了以下错误:

ssh: connect to host usts.visualstudio.com port 22: Bad file number
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

你不能“撤消”一个git remote rm call。

此外,您不需要撤消git rm 只需按指示运行命令即可。

或者只是运行git push origin master (或者你正在使用的任何分支)。

git remote rm origin删除与远程服务器的连接。 git remote add origin <user>@<url>将重新创建此连接。 看起来好像当你运行git remote add origin <user>@<url>时输入了错误的url或错误的用户名。 也许只是一个错字。

要检查,请运行git remote -v 这将显示当前配置的远程存储库的连接字符串。 请根据Visual Studio Online提供的文档进行检查。 如果它是错误的,只需再次执行git remote rm origin ,然后再使用正确的详细信息git remote add origin <user>@<url>

如果您不确定我的意思或者您已经尝试了这个并且它不起作用,那么请发布您正在使用的确切命令以及git remote -v的确切输出,我将看看是否可以找到错误。

要解决此问题,您需要告诉git您的本地主分支跟踪远程分支,这是错误告诉您要执行的操作。 通过运行git push --set-upstream origin master ,你告诉git当前分支跟踪origin / master

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM