Skip to content

Instantly share code, notes, and snippets.

@nara-l
Last active December 20, 2019 21:01
Show Gist options
  • Save nara-l/39d3ef0725337ed31075fcde4cac099b to your computer and use it in GitHub Desktop.
Save nara-l/39d3ef0725337ed31075fcde4cac099b to your computer and use it in GitHub Desktop.
GIT: Cherry Picking commits from another branch to a new branch git
# Picking specific commits from one git branch to a new one
#. 1. Create a new branch off master or any clean branch and checkout into the new branch
# 2. Use git log --pretty=oneline # on the branch with the needed commits to see the <sha> for the commits needed
# command
git cherry-pick 108e055..3f7cf07 # does not include commits from 108e055. 108e055 being the oldest commit and 3f7cf07 the lastest
git cherry-pick 108e055^..3f7cf07 # to include commits from 108e055
# usually you need to do a git add . and git commit to add the new files and create new commit message for the moved files
#cherry picking the last commit
git cherry-pick [branch_to_cherry_pick_from] . # it could be master as well
# cherry-pick 1 commit
You are currently cherry-picking commit d856905
# git show 28703c6f , to show history of sha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment