Thursday, August 18, 2016

Unleashing the Git - part 7 - Cherry picking commits

We looked at git branching in one of my previous post. In this post let's look at git's on of the unique and powerful features that ties with branching; cherry-picking.  

You might need to merge only a specific commit in a branch to your local branch, rather than merging an entire branch. Opt to cherry pick only if merging is not an option. One use case where you want to cherry pick is to back port a bug fix you have done in another branch.

Since we covered some branching concepts in the previous post, let's remind a few commands first.

To see all the available branches
$ git branch
To switch to another branch
$ git checkout <branch name>
Cherry picking a branch, tag or a specific commit could be done using the following command.
$ git cherry-pick <branch name, tag name or commit id>   // In case of branch or tag name, only the latest commit will be picked.

Cherry picking also does the commit. You can avoid the commit with the following. This is important when you want to cherry pick multiple commits and commit all stages at once to commit in the current branch.
$ git cherry-pick --no-commit release_branch_v1 // Or same as $ git cherry-pick --n release_branch_v1
$ git cherry-pick --edit <commit id>   // launches the editor to change te commit message. Same as $ git cherry-pick -e <commit id>
$ git cherry-pick --signoff release_branch_v1   // Adds a “Signed-off-by” line followed by your name and email taken from configuration to the commit message. Same as $ git cherry-pick -s release_branch_v1

1 comment:

  1. Did you realize there is a 12 word sentence you can speak to your man... that will trigger intense feelings of love and impulsive attraction to you buried within his heart?

    Because deep inside these 12 words is a "secret signal" that triggers a man's impulse to love, adore and protect you with his entire heart...

    12 Words That Trigger A Man's Love Impulse

    This impulse is so built-in to a man's mind that it will make him try harder than before to do his best at looking after your relationship.

    Matter of fact, fueling this powerful impulse is so mandatory to getting the best possible relationship with your man that the instance you send your man a "Secret Signal"...

    ...You'll instantly notice him expose his heart and mind to you in such a way he's never expressed before and he'll recognize you as the only woman in the universe who has ever truly attracted him.

    ReplyDelete