美文网首页
本地分支默认自动关联远程分支

本地分支默认自动关联远程分支

作者: holidayPenguin | 来源:发表于2022-09-18 11:37 被阅读0次

    场景

    拉取远程分支以后首次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
    

    推送成功

    相关文章

      网友评论

          本文标题:本地分支默认自动关联远程分支

          本文链接:https://www.haomeiwen.com/subject/hahportx.html