SO处理如何更改push
命令的参数以避免此消息的相关问题:
致命:当前分支的上游分支与当前分支的名称不匹配
我感兴趣的是如何在不更改本地/远程分支名称或使用花哨的push
命令的情况下压制消息本身。
假设我有一个本地分支跟踪一个不同名称的远程分支:
user@home:~ git branch -vv
branch-name abcd1234 [remote/origin/branch-name] last commit message
现在,我希望能够通过简单地键入git push
来推动我提交的更改。当我这样做时,我会得到以下消息:
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(1.9或更新版本)
git config --global push.default upstream
较旧的Git
git config --global push.default tracking
Git 2.3仍然接受tracking
作为上游的同义词
只需执行一次,无论何时"git-push",它都会将当前分支推送到其配置的上游。
这也会在全局配置中设置它,而全局配置可能会被存储库配置中的其他设置遮蔽。