简体   繁体   English

在git中创建一个新的分支,省略一个提交

[英]creating a new branch in git with one commit omitted

I have 2 branches in my project branch1 and branch2. 我的项目branch1和branch2中有2个分支。

This is the order of commits on the branches. 这是分支上的提交顺序。

output of git log on branch1: branch1上的git log输出:

commit 'a'
commit 'b'
commit 'c'
commit 'd'

output of git log on branch2: branch2上的git log输出:

commit 'f'
commit 'e'
commit 'c' 
commit 'd'

and I would like to create a new branch which in sync with branch1 and also have the changes that are in just commit 'f'. 我想创建一个与branch1同步的新分支,并且还具有提交'f'的更改。

so the new branch commits should look like this 所以新的分支提交应该是这样的

commit 'f'
commit 'a'
commit 'b'
commit 'c'
commit 'd'

How to proceed with this one? 如何处理这个?

git checkout -b [new branch name]
git cherry-pick [hash of commit 'f']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM