如何在git中快速转发其他跟踪分支? [英] How do I fast-forward other tracking branches in git?

查看:107
本文介绍了如何在git中快速转发其他跟踪分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用我们所有人使用的单个远程存储库的模型。我们为新功能分支并重新集成到主干分支。我们的工作流程是,当其他功能集成到中继线时,我们应该从中继线集成到我们的工作分支中。

We are working with the model of a single remote repository that all of us use. We branch for new features and reintegrate into a trunk branch. Our workflow is that we should integrate from trunk into our working branches when other features are integrated into the trunk.

因此,我们做这件事并不少见: p>

As such, it's not uncommon for us to do:

(branch) $ git commit -a -m"blah blah blah"
(branch) $ git fetch  # origin/trunk is updated
(branch) $ git checkout trunk
(trunk) $ git pull  # trunk is fast-forwarded to current version of origin/trunk.
(trunk) $ git checkout branch
(branch) $ git merge trunk
(branch) $ git push

我不喜欢git checkout trunk / git pull / git checkout branch循环。它通常与Visual Studio结合,抱怨说我的所有文件和项目都在磁盘上发生了变化,并且它应该重新加载它们。两个结帐。和拉。并合并。合并是不可避免的,但由于git的工作原理,它应该能够在trunk上快速转发,而无需实际检查出来。

I don't like the "git checkout trunk/git pull/git checkout branch" cycle. It's usually combined with Visual Studio complaining that all my files and projects have changed on disk, and should it reload them. For both checkouts. And the pull. And the merge. The merge is unavoidable, but because of how git works, it should be able to do the fast-forward on trunk without actually needing to check it out.

但我不知道不知道命令,我的google-foo在这方面让我失望了。任何人都知道如何?

But I don't know the command, and my google-foo has failed me on this. Anyone know how?

推荐答案

你真的需要更新本地的 trunk 分支?

Do you really need to update a local trunk branch?

只需获取origin / trunk 合并它直接在你正在开发的分支中。

这就是 Mark Longair ' s的建议: git: fetch merge ,请勿

Just fetch origin/trunk and merge it directly in the branch you are working on.
And that is Mark Longair's advice: git: fetch and merge, don’t pull.

Oliver a>在他的回答中提到(upvoted):

Oliver mentions in his answer (upvoted):

git fetch upstream trunk:trunk

由于

As he comments:


您可以跳过合并并简单地快进,使用单线。

它将本地分支 trunk 快进到远程分支的HEAD 。

It does fast-forward the local branch trunk to the remote branch's HEAD.

详情请参阅 git:更新本地分支而不检出?

这篇关于如何在git中快速转发其他跟踪分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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