Git:表示来源已经存在于“NEW” (初始化)存储库,使用shell但安装github for windows [英] Git: says origin already exists on "NEW" (init) repository, using shell but installed github for windows
问题描述
我为Windows安装了git,但我使用的不是windows界面的shell。
如果我做了一个git init。然后尝试做一个
git remote add origin git@github.com:someuser / testme.git
我收到以下错误:
致命:远程原点已经存在。
所以我做了一个
git remote -v
它会返回以下内容:
出身
上游
所以它出现在那里,但没有设置网址,我不明白为什么它那里?
如果我做了一个
git remote rm origin
它产生了这个
错误:无法删除配置节'remote.origin'
它说它可以'删除remote.origin配置部分..我检查了我的主目录下的.gitconfig,我什么也没看到......
无论如何,我能够通过使用
git remote set-url origin git@github.com:someuser / testme.git
但是我感到困惑,因为我之前使用过git,而且这种情况从未发生过..
这可能与git f有关或者窗户?
任何帮助都会得到真正的赞赏。 我是开发人员把它放在这里。这就是为什么我将它添加到系统gitconfig,它非常有用!
##因为这个变化,git fetch知道PR
git fetch
##现在,我可以通过数字
合并PRs git merge origin / pr / 24
##查看来自PR#53的变化
git diff master ... origin / pr / 53
##从PR#25获取提交日志
git log原产地/ pr / 25
不幸的是,这确实会造成远程始终存在的结果,它不会。
解决方法
每当您看到 git remote add origin https :// ...
,而不是:
git remote set-url原点https:// ...
I wonder if anyone can help?
I installed git for windows, although i am using the shell not the windows interface.
if I do a git init. and then try and do a
git remote add origin git@github.com:someuser/testme.git
I get the following error
fatal: remote origin already exists.
So I do a
git remote -v
and it returns the following
origin upstream
SO it appears its there but has no url set, i don't understand why its there?
If I do a
git remote rm origin
it produces this
error: Could not remove config section 'remote.origin'
It says that it can't remove the remote.origin config section.. I checked the .gitconfig under my home directory and i don't see anything...
Anyway I was able to remedy this by using
git remote set-url origin git@github.com:someuser/testme.git
But i am getting confused as I have used git before and this never happend..
Could this be something to do with git for windows?
Any help would be really appreciated.
I'm the developer who put this in. Here's why I added this to the system gitconfig, it's pretty useful!
## Because of this change, git fetch knows about PRs
git fetch
## Now, I can merge PRs by number
git merge origin/pr/24
## See changes from PR #53
git diff master...origin/pr/53
## Get the commit log from PR #25
git log origin/pr/25
Unfortunately, this does have the consequence that the origin remote always exists, even when it doesn't.
Workaround
Whenever you see git remote add origin https://...
, instead:
git remote set-url origin https://...
这篇关于Git:表示来源已经存在于“NEW” (初始化)存储库,使用shell但安装github for windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!