git pull currently tracked branch

僤鯓⒐⒋嵵緔 提交于 2019-12-11 08:44:40

问题


I use git checkout -b somebranch origin/somebranch to make sure my local branches track remotes already. I would like a way to pull from the tracked branch no matter which branch I am using. In other words, I want to say git pull or some other command, without specifying the branch, and have it mean git pull origin somebranch if I'm on the local branch somebranch

Is there a way to do this without putting an entry in the config file for each branch? It would be difficult to maintain if we have to remember to manually enter some config stuff for each branch.


回答1:


I am not sure this is possible unless you have first tracked oll the branches from origin repo (see the SO question "Track all remote git branches as local branches")

The other solution would be (not tested) to make a alias for:

$ git pull refs/heads/*:refs/remotes/origin/*

From git pull man page:

The above specifies that all remote branches are tracked using tracking branches in refs/remotes/origin/ hierarchy under the same name.



来源:https://stackoverflow.com/questions/2471879/git-pull-currently-tracked-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!