How to cherry-pick commits on GitHub Pull Request

0
7282
Git
Git

When your repositories have PR with a lot of commits, you might want to select and apply only several commits out of them, git-cherry-pick is what you’re likely to use.

Here the steps taken during cherry-pick:


$ git log --oneline
$ git checkout -b save-master master
$ git pull FORK_GIT_URL master

$ git checkout master
$ git cherry-pick HASH_ID
...

$ git log --oneline
$ git push origin master
$ git branch -D save-master

Above commands are self-explanatory enough for you I guess. You can cherry-pick any commit you want to merge. If there is any problem during cherry-pick, you can just stop and restart cherry-pick again.


$ git cherry-pick --abort

or

$ git reset

This is applied to all popular Git servers, including GitHub, BitBucket and GitLab.