Copy changes of commits in Git

If you just want to apply changes of some certain commits in other branch, cherry-pick command works for you. It picks changes from the selected commits and apply them on another branch:

# Apply the changes introduced by commit 95f2137 and
# create a new commit with the change
$ git cherry-pick 95f2137

# Apply the changes introduced by tip commit of develop branch
$ git cherry-pick develop

You can also specify multiple commits :

# Apply the changes introduced by the third last commit and 
# the tip commit on develop branch and create 2 new commits.
$ git cherry-pick develp~2 develop~

# Apply the changes introduced by all commits that are ancestors of develop or topic, but not any commits on master.
$ git cherry-pick develop topic ^master

If you want to copy changes in working directory and staging area without committing them, add -n or --no-commit option :

# Apply the changes introduced by tip commit of develop branch 
# in working tree and staging area, but not commit the changes.
$ git cherry-pick --no-commit develop