场景
拉取远程分支以后首次git push
后,就提示要关联远程分支,每次都是手动操作关联。
操作流程
首先获取远程所有最新的信息
git fetch
fetch拉取远程分支
git fetch origin featrue/xxx:featrue/xxx
代码修改好需要推送代码
git push
这时提示需要关联远程分支
fatal: The current branch featrue/xxx has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin featrue/xxx
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
然后就是复制提示的命令去执行,最后再重新推送代码
解决办法
如何才能不用每次都要操作一下呢?提示信息已经给出答案了,注意后面的 push.autoSetupRemote
,就是这个。
需要将 push.autoSetupRemote
指定为true就可以了
git config --global push.autoSetupRemote true
然后继续执行代码推送
git push
推送成功
网友评论