我正在处理本地化,这是一个迭代40多个分支的过程,每个分支都实现了大约40个提交。其中一些(比方说一半),几乎对所有的分支都是完全一样的。因此,我开始将提交ID (比如085cfefc9291b)复制到记事本中,然后当我希望在我的当前分支上实现这些更改时,我会从列表中选择。
我为 cherry-pick
(前)提交的列表。git cherry-pick 290d953c2837
):
这些提交来自同一个存储库的不同分支。
一些非常适合我的工作流程的东西,可以将这些提交绑定/压缩成一个提交。这将使我能够动态地创建整个过程中的修补程序,如果我保留了长长的单独的通信列表,我可以很容易地创建不同版本的修补程序,其中一些版本中提交的更多,有些版本更少。
你知道这方面的最佳做法是什么?
发布于 2018-02-07 17:59:05
假设您有一组提交{A,B,C,D,E,F,G}
和一个基本提交Z
。压缩A B C F
的过程类似于:
#create a branch patch1 from Z
git checkout -b patch1 Z
#apply A B C F
git cherry-pick A B C F
#squash them into one commit
git reset Z --soft
git commit -m 'squash A B C F'
#create a patch of the new commit if necessary
git format-patch -1
这只是创建这样一个组合提交的可能方法之一。很难决定哪一次提交才是合适的基础。
另一种方法:
#create a branch patch1 from G
git branch patch1 G
#rebase and squash A B C F onto Z
git rebase -i --onto Z A^..patch1
#in the editor
pick A
squash B
squash C
squash F
#create a patch of the new commit if necessary
git format-patch -1
https://stackoverflow.com/questions/48665816
复制相似问题