在SO上有一个相关的问题,涉及如何更改push命令的参数以避免此消息:
我对如何压制消息本身感兴趣,而不更改本地/远程分支的名称或使用花哨的push命令.
假设我有一个本地分支跟踪一个不同名称的远程分支:
user@home:~ git branch -vv
branch-name abcd1234 [remote/origin/branch-name] last commit message
Run Code Online (Sandbox Code Playgroud)
现在我想通过简单的输入来推动我的提交更改git push.当我这样做时,我收到以下消息:
Run Code Online (Sandbox Code Playgroud)fatal: The upstream branch of your current branch does not match the name of your current branch. To push to the upstream branch on the remote, use git push origin HEAD:remote/origin/branch-name To push to the branch of the same name on the remote, use git push origin branch-name
git即使名称不匹配,如何强制自动推送到上游分支?我正在使用git 1.9.1
较新的Git(v 1.9或更新版本)
git config --global push.default upstream
Run Code Online (Sandbox Code Playgroud)
年长的Git
git config --global push.default tracking
Run Code Online (Sandbox Code Playgroud)
Git 2.3仍然接受tracking上游的同义词
只需执行一次,每当"git push"时,它会将当前分支推送到其配置的上游.
这也将它设置在您的全局配置中,该配置可能会被存储库配置中的其他设置所遮蔽.