How can I push a local Git branch to a remote with a different name easily?

前端 未结 5 1467
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 16:38

I\'ve been wondering if there\'s an easy way to push and pull a local branch with a remote branch with a different name without always specifying both names.

For exa

5条回答
  •  隐瞒了意图╮
    2020-11-30 17:20

    Sure. Just set your push.default to upstream to push branches to their upstreams (which is the same that pull will pull from, defined by branch.newb.merge), rather than pushing branches to ones matching in name (which is the default setting for push.default, matching).

    git config push.default upstream
    

    Note that this used to be called tracking not upstream before Git 1.7.4.2, so if you're using an older version of Git, use tracking instead. The push.default option was added in Git 1.6.4, so if you're on an older version than that, you won't have this option at all and will need to explicitly specify the branch to push to.

提交回复
热议问题