Mjam! git cherry-pick

Image CC BY-NC 2.0 by moriza on flickr

Each day you didn’t know about how to use git-cherry-pick is half a developer’s day. Kind of my feeling after this week has passed.

It allows to take one commit from another branch and add it to the current branch. A commit becomes like a patch file that you pass around and applies on another branch. You just do not need to create any files😉. For example while you implement a new feature and you run over a general bug and you want to have this fixed in more then only your current feature branch.

What you can do then is to commit the fix in your feature branch, note the commit’s SHA1-ID (or some of it’s beginning first chars) and with it you can apply it later on the stable branch with git-cherry-pick.

git cherry-pick SHA1-ID will commit the changes unless you make use of the -n switch, which will apply the changes but not commit them.

This done you can ensure that a fix is not lost in current “upstream” while you still can fiddle with your new feature. That’s nice.

And if someone else found a fix, you can naturally cherry-pick it as well into your current branch. How flexible!

Read On: git cherry-pick wins

This entry was posted in Hakre's Tips, Linked, Pressed, Tools, Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s