gpt4 book ai didi

git - "Keeping up"与远程主机在长期本地主题分支上工作时

转载 作者:太空狗 更新时间:2023-10-29 12:54:05 29 4
gpt4 key购买 nike

我已经在本地主题分支 上工作了一段时间,偶尔只做一些更改。

与此同时,ma​​ster 分支有了显着的发展。我决定将 master 分支中的新更改 merge 到我的本地主题分支中(与我从中分支出来的原始 master 提交相比几乎没有任何更改):

git fetch
git checkout my_branch
git merge origin/master

但是 git 警告我:

Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch.

这让我很好奇。为什么警告?我应该改为做 rebase 吗?还是cherry-pick?除此之外,我将如何在我的案例中使用 rebase 或 cherry-pick?

最佳答案

已经与 git 的核心维护者讨论了这个确切消息的措辞,因为你是对的,它不是很清楚。

puppet labs 编程指南很好地解释了为什么这是次优的,并提供了更可取的解决方法:

Work should be done on topic branches and merged in using no-ff. The reason for this is that the git history then becomes a lot clearer. The topic branches group related commits nicely, and merging using no-ff preserves that grouping in history.

Don’t merge your upstream branch into your topic branch if you can possibly avoid it. While this is one way to resolve conflicts between your development and development in the upstream branch, it leads to an unclean history – and especially to having code changes in merge commits, which are super-hard to work with.

We would prefer that you rebase your branch against upstream, so that we don’t wind up with that mess, if you have to adapt to external changes.

Puppet Labs

关于git - "Keeping up"与远程主机在长期本地主题分支上工作时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12842698/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com