为什么 git 不拉?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5912720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is git not pulling?
提问by Ben Griffiths
I created a local branch like so
我像这样创建了一个本地分支
$ git branch group_contact_form
I committed some changes then sent the branch to remote like so:
我提交了一些更改,然后将分支发送到远程,如下所示:
$ git push origin group_contact_form
I can quite happily keep pushing commits and $ git branch -a
displays my local and remote branch
我可以很高兴地继续推送提交并$ git branch -a
显示我的本地和远程分支
* group_contact_form
master
remotes/origin/HEAD -> origin/master
...
remotes/origin/group_contact_form
...
But, when I try to pull with $ git pull
:
但是,当我尝试使用$ git pull
:
fatal: 'origin/group_contact_form' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
My .git/config
is as follows:
我.git/config
的如下:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = database1:/var/git/repo_name.git
[branch "master"]
remote = origin
merge = refs/heads/master
[branch "group_contact_form"]
remote = origin/group_contact_form
merge = refs/heads/master
What have I done wrong?
我做错了什么?
采纳答案by evnu
Your merge
setting in the section branch "group_contact_form"
seems to be wrong. I think it should be
您merge
在该部分中的设置branch "group_contact_form"
似乎有误。我认为应该是
merge = refs/heads/group_contact_form
Additionally, remote
should be
此外,remote
应
remote = origin
That's the setting I receive after executing git push origin mybranch
.
这是我执行后收到的设置git push origin mybranch
。
回答by Pablo Fernandez
You should execute:
你应该执行:
git remote show origin
This will give you a list of which local branches are tracking branches
这将为您提供哪些本地分支机构正在跟踪分支机构的列表
If your local branch is not tracking the remote, you can create a tracking branch with:
如果您的本地分支没有跟踪远程,您可以使用以下命令创建跟踪分支:
git checkout -b origin/group_contact_form
Then just rebase your local branch so you can update the changes
然后只需重新设置您的本地分支,以便您可以更新更改
回答by ralphtheninja
Try the following:
请尝试以下操作:
git branch --set-upstream group_contact_form origin/group_contact_form