Level: Rewriting History 4 - "Cherry-Picking"
- Dominant language
- Python
- Stars
- 558
- Forks
- 53
- PR merge metrics
- No merged PRs in 30d
Description
```
4) Cherry-picking - Cherry-picking is another action that changes the hash
```
Cherry-picking writes a new commit (with a new hash), but instead of changing the content like amending, cherry-picking will change the commit's parent.
Cherry-picking is for when you want to apply the changes from only one commit.
`git gud status`
```
Initial Commit (master):
Hash:
Files: File1
Work1:
Hash:
Files: File1, BadFile
Work2 (branch):
Hash:
Files: File1, BadFile, File2
By the way, you can see the difference here:
======= Simulating: git diff branch~ branch
Work2 added a File2!
<<<<<<<
======= Simulating: git log --oneline --all --graph
Blah
<<<<<<<
```
`git gud status` (after cherry-picking)
```
Initial Commit (master):
Hash:
Files: File1
Work1:
Hash:
Files: File1, BadFile
Work2 (branch):
Hash:
Files: File1, BadFile, File2
Work2 (master):
Hash:
Files: File1, File2
By the way, you can see the difference here:
======= Simulating: git diff master~ master
Work2 added a File2!
<<<<<<<
By the way, you can see the difference here:
======= Simulating: git diff branch~ branch
Work2 added a File2!
<<<<<<<
======= Simulating: git log --oneline --all --graph
Blah
<<<<<<<
```
Tree:
```
A) Starting tree
Initial (master)
\
work1 --- work2 (branch)
B) After rebasing
Initial --- work2'
\
work1 --- work2 (branch)
C)
Initial --- work2' --- Merge (master)
\ /
work1 --- work2 (branch)
```
Contributor guide
Assessment
This issue has not been assessed yet.