英文:
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
- 将所有仓库的分支推送到它们通过
push.default来拉取的地方。 - 通过
remote.<name>.push进行分支配置。
英文:
Two options:
pushall the repo's branches to where they get pulled from viapush.default- 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):
-
Set the branch's remote
git branch --set-upstream-to origin -
Set the remote's push mapping
git config --local remote.origin.push main:master
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论