I have following repository
A-B-C-D-E-F-G-H-I-J-K-L
And I want to do:
A-B-C-D-E-F-G-H-I-J-K-L
\
C-D-E-F-G-H
And move new branch on top of master
A-B-C-D-E-F-G-H-I-J-K-L
\
C-D-E-F-G-H
So I did:
checkout B
checkout -b new-branch
cherry-pick C D E F G H
// so far it what i want
rebase new-branch master
// now I'm back in master like I did nothing
Not sure how to achieve this.
// EDIT
Commit I
is Revert from github UI, so it's commits CDEFGH
squashed together. (Or I
is merge commit and J
is revert commit.)
If you want commit C, D, E, F, G, H on their own branch without I, J , K, and L, you should do this:
git checkout H
git checkout -b new-branch
After adding a few more commits on new-branch, your history would look like:
master: A-B-C-D-E-F-G-H-I-J-K-L
\
new-branch: M-N-O
Once you have worked on new-branch some and have some commits, you can use rebase to play the differing commits on top of master like this:
git checkout new-branch
git rebase master
That would make your history look like this:
master: A-B-C-D-E-F-G-H-I-J-K-L
\
new-branch: M-N-O
尝试直接从 master 挑选一系列所需的提交。
git cherry-pick C..H
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.