Git之cherry-pick: 合并指定的commit

版权声明:转载请注明出处,谢谢。 https://blog.csdn.net/butterfly5211314/article/details/82628377

git cherry-pick可以合并一个区间的提交. 比如现在有两个分支, 其提交情况分别如下:

master分支:
24e6c97 (HEAD -> master, dev) initialized
hotfix分支:
e29815f (HEAD -> hotfix) fix bug 7
9bec248 fix bug 6
962c211 fix bug 5
43bfbb9 fix bug 4
66aa7d1 fix bug 3
b42e69d fix bug 2
7027ac8 fix bug 1
24e6c97 (master, dev) initialized

其中hotfix是从master(从提交24e6c97)开出来的, 后面有7次提交(fix bug 1, 2, …, 7).

然后我想将hotfix的第2次提交(fix bug 2)合并到master分支, 因为后面几个发现提交的是错的.
可以这样:

git cherry-pick b42e69d

然后就和git merge一样, 有冲突解决下冲突, 然后git add & git commit.
这样就可以合并指定的commit.


参考:
https://blog.csdn.net/w958796636/article/details/78492017
https://git-scm.com/docs/git-cherry-pick


欢迎补充指正.

猜你喜欢

转载自blog.csdn.net/butterfly5211314/article/details/82628377