在您的alice存储库中尝试此操作(在推送之前):
git config push.default tracking
或者,使用将其配置为用户的默认设置git config --global …。
git push确实默认为origin存储库(通常是您从中克隆当前存储库的存储库),但是它不默认为推送当前分支-默认为仅推送源存储库和目标存储库中都存在的分支。
该push.default配置变量(见的git-配置(1) )控制什么git push时候(存储库名称后,即东西)没有给出任何“的Refspec”参数将推动。默认值提供上述行为。
以下是可能的值push.default:
nothing
这迫使您提供“ refspec”。
matching(默认)
这将推送源存储库和目标存储库中都存在的所有分支。
这完全独立于当前签出的分支。
upstream或tracking
(两个值表示相同的含义。不推荐使用后者,以避免与“远程跟踪”分支混淆。前者是在1.7.4.2中引入的,因此,如果您使用的是Git 1.7.3.1。,则必须使用后者。 )
这些将当前分支推送到其“上游”配置指定的分支。
current
这会将当前分支推送到目标存储库中具有相同名称的分支。
对于通常情况(例如在使用Origin / master作为上游的本地master上工作),这最后两个最终是相同的,但是当本地分支的名称不同于其“上游”分支时,它们是不同的:
git checkout master
# hack, commit, hack, commit
# bug report comes in, we want a fix on master without the above commits
git checkout -b quickfix origin/master # "upstream" is master on origin
# fix, commit
git push
随着push.default等于upstream(或tracking),推送会去origin的主分支。当等于时current,推送将转到origin的quickfix分支。
建立后,该matching设置将在您的方案中更新bare的主文件。要建立它,您可以使用git push origin master一次。
但是,该upstream设置(或也许current)似乎与您希望发生的情况更好地匹配,因此您可能想尝试一下:
# try it once (in Git 1.7.2 and later)
git -c push.default=upstream push
# configure it for only this repository
git config push.default upstream
# configure it for all repositories that do not override it themselves
git config --global push.default upstream
(同样,如果您在1.7.4.2之前仍在使用Git,则需要使用tracking代替upstream)。