可以“git pull --all"吗?更新我所有的本地分支机构? [英] Can "git pull --all" update all my local branches?

查看:25
本文介绍了可以“git pull --all"吗?更新我所有的本地分支机构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常有至少 3 个远程分支:master、staging 和 production.我有 3 个本地分支来跟踪这些远程分支.

I often have at least 3 remote branches: master, staging and production. I have 3 local branches that track those remote branches.

更新我所有的本地分支很乏味:

Updating all my local branches is tedious:

git fetch --all
git rebase origin/master
git checkout staging
git rebase origin/staging
git checkout production
git rebase origin/production

我很想能够只做一个git pull -all",但我一直无法让它工作.它似乎执行fetch --all",然后更新(快进或合并)当前工作分支,而不是其他本地分支.

I'd love to be able to just do a "git pull -all", but I haven't been able to get it to work. It seems to do a "fetch --all", then updates (fast forward or merges) the current working branch, but not the other local branches.

我仍然无法手动切换到每个本地分支并进行更新.

I'm still stuck manually switching to each local branch and updating.

推荐答案

您为 pull --all 描述的行为完全符合预期,但不一定有用.该选项传递给 git fetch,然后它从所有遥控器中获取所有引用,而不仅仅是需要的引用;pull 然后合并(或者在你的情况下,rebases)适当的单个分支.

The behavior you describe for pull --all is exactly as expected, though not necessarily useful. The option is passed along to git fetch, which then fetches all refs from all remotes, instead of just the needed one; pull then merges (or in your case, rebases) the appropriate single branch.

如果您想查看其他分支,则必须查看它们.是的,合并(和变基)绝对需要一个工作树,所以如果不检查其他分支就无法完成.如果您愿意,您可以将您描述的步骤包装到脚本/别名中,但我建议使用 && 加入命令,这样如果其中一个失败,它就不会尝试继续耕耘.

If you want to check out other branches, you're going to have to check them out. And yes, merging (and rebasing) absolutely require a work tree, so they cannot be done without checking out the other branches. You could wrap up your described steps into a script/alias if you like, though I'd suggest joining the commands with && so that should one of them fail, it won't try to plow on.

这篇关于可以“git pull --all"吗?更新我所有的本地分支机构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆