git cherry-pick abcd0123
A commit exists on a feature branch, let’s call that
Let’s head back to our sample repository and add a new commit to
$ echo 4 >> new_file $ git add new_file $ git commit -m 'forth commit' $ git log --oneline --decorate --all --graph
* 87b5eff (HEAD -> branch_a) forth commit * c890001 thirdcommit | * 1094303 (master) secondcommit |/ * 16797ce (tag: first_commit_tag) first commit m8
Now we can see the commit we made. Let’s checkout
$ git checkout master
Now say we just wanted that
87b5eff forth commit on master, and not
c890001 third commit… We could
cherry-pick just that change on to our master branch, so we wouldn’t have to merge the whole branch over, just that commit.
git cherry-pick 87b5eff
* 74d1d09 (HEAD -> master) forth commit * 1094303 secondcommit | * 87b5eff (branch_a) forth commit | * c890001 thirdcommit |/ * 16797ce (tag: first_commit_tag) first commit m8
Now that we know about
cherry-pick, lets take a look at
git reset and resetting changes.