将默认推送到的远程分支设置为

huangapple go评论61阅读模式
英文:

Set the remote branch pushed to by default

问题

我想为我的本地分支设置push默认远程分支。

例如,我希望我的本地分支main推送到origin/master

我尝试过:

git branch --set-upstream-to origin/master

但这只适用于fetch / pull。对于push,我仍然需要执行:

git push origin main:master

我该如何设置,以便只需执行简单的git push

英文:

I want to setup the push default remote branch for my local branch.

Eg, I want my local branch main to push to origin/master.

I've tried:

git branch --set-upstream-to origin/master

But this only works for fetch / pull. For push, I still need to do:

git push origin main:master

How can I set it up so that I only need to do a simple git push?

答案1

得分: 1

  1. 所有仓库的分支推送到它们通过push.default来拉取的地方。
  2. 通过remote.<name>.push进行分支配置。
英文:

Two options:

  1. push all the repo's branches to where they get pulled from via push.default
  2. Per-branch config via remote.<name>.push

To have all your repo's branches push to the branch that they pull from, use:

git config --local push.default upstream

Note: this will affect other branches, also.


To setup a single branch's remote push pair (Example: local main to origin/master):

  1. Set the branch's remote

     git branch --set-upstream-to origin
    
  2. Set the remote's push mapping

    git config --local remote.origin.push main:master
    

huangapple
  • 本文由 发表于 2023年6月29日 13:09:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/76578201.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定