我不知道我是否误用了Git,或者我是否遇到配置问题,所以任何清晰度都会受到赞赏:)
我将github repos克隆到机器A和B上,然后在机器A上克隆:
git checkout -b branchA
// make edits
git add .
git commit -am "initial"
git push
然后在机器B上我做
git pull
git checkout branchA
// make edits
git commit -am "edits"
git push
然后在机器A上执行:
git pull
然而它说:
There is no tracking information for the current branch
所以我必须这样做:
git branch --set-upstream branchA origin/branchA
:/为什么我必须设置上游,当它最初将它推送到origin / branchA时没有问题?
怎么回事?感谢
我正在使用msygit 1.8。在Windows上
P.S。当我在机器B上执行pull
时,为什么默认情况下不会跟踪新分支branchA
? git branch
没有显示它(但它与-r
一起显示)。我可以在pull?
答案 0 :(得分:12)
因为git config push.default
没有返回任何内容,这意味着,使用“git 1.8.0.msysgit.0”,您的git push
表示git push origin :
,其中refspec'{{1代表“匹配”分支。
这里它在远程端创建匹配的:
。
但这并不能使它成为一个远程跟踪分支
换句话说,branchA
未设置为任何内容
这就是git pull失败的原因:它不知道它应该合并到本地branch.branchA.merge
的远程分支。
注意,您的第一个branchA
应该显示以下消息:
git push
因此,使用Git2.0,git push会失败
推送warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
的唯一方法是明确设置其上游分支(使用相同的名称):
branchA