loading...

How often do you use git cherry-pick?

yujiri8 profile image Ryan Westlund ・1 min read

I don't see git cherry-pick mentioned much, but I find it extremely useful. Useful enough that I made a shell alias gtpk for it.

Discussion

markdown guide
 

I use it when I am in-between tasks.

Working on Task A then a simple fix is needed on the development branch and changing to a new fix/feature branch is just too much of a hassle.
Make the commit on the current Task A feature branch and cherry-pick it into the development branch.

 

My last employer was product based, we had to patch the issues also to previous versions.
Each version had its own branch, so we used to apply the fix in the current develop branch and cherry pick fixes to previous version, that had saved quite some time.

Another scenario was when multiple devs would be working on a common feature.

  • In case the other dev had no breaking changes, pull from their branch was nice.
  • This was not very ideal situation; because often there were some unnecessary changes/commit in other dev's branch, hence most times cherry picking get specific updates from other dev's branch was handy.
 

Usually when I screw something up haha
I've used it maybe a handful of times, and it was mostly when I forgot to switch branches

 
 

Same here, I’ve been committing changes to the wrong branch lately and cherry-pick has been the saviour

 
 

In short: never.
If nor me, nor my colleagues screw up anything, then never.

In long:
Like once under 3 years. And not sure it is a good idea to use it at all. (We used it for picking features into a separated release branch).

 
 
 

I use it in a full git flow: devel and master branches, hotfix branches merged into master, and feature branches merged into devel. I cherry pick hotfix commits (already in master) to devel

 

I work on teams that do trunk-based development. Release managers use cherry-pick to bring features to the release branch from master.

 

A lot, picking commits from staging to pre-prod, pre-prod to prod

 

I'm not sure about other shells, but in bash aliases were effectively deprecated prior to 1996. If you are still using aliases, you should consider updating your workflow.

 

This is a feature that has always sounded like a killer feature yet I've never actually used it.