Questions tagged [git-cherry-pick]

This command applies the changes introduced by some existing commits.

Given one or more existing commits, apply the change each one introduces, recording a new commit for each. This requires your working tree to be clean (no modifications from the HEAD commit).

When it is not obvious how to apply a change, the following happens:

  • The current branch and HEAD pointer stay at the last commit successfully made.

  • The CHERRY_PICK_HEAD ref is set to point at the commit that introduced the change that is difficult to apply.

  • Paths in which the change applied cleanly are updated both in the index file and in your working tree.

  • For conflicting paths, the index file records up to three versions, as described in the "TRUE MERGE" section of git-merge(1). The working tree files will include a description of the conflict bracketed by the usual conflict markers <<<<<<< and >>>>>>>.

  • No other modifications are made.

See git-merge for some hints on resolving such conflicts.

Links

376 questions
11
votes
1 answer

What 'cherry' means in git-cherry?

What is the meaning of the word cherry in git-cherry? Besides the fruit, I've only seem the word in the cherry picking expression (also present in git with git-cherry-pick), that means selectively picking something (right?). Doesn't look like to me…
talles
  • 14,356
  • 8
  • 45
  • 58
11
votes
3 answers

Git: How to merge upstream changes without causing a merge commit?

I have (commits were created in alphabetical order) origin/topic A-B-C-D-W-X topic A-B-C-D-Y-Z Is there a way i can get my topic branch to look like A-B-C-D-W-X-Y-Z without introducing a merge commit? Ordinarily I'd just do $ git…
Mulan
  • 129,518
  • 31
  • 228
  • 259
10
votes
2 answers

What's different between `--abort` and `--quit` as sequencer subcommands for `cherry-pick`?

As per the doc, among the three sequencer subcommands for cherry-pick, we have these two which are, to me, oddly similar : --quit Forget about the current operation in progress. Can be used to clear the sequencer state after a failed cherry-pick…
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
10
votes
2 answers

What is the difference between git cherry-pick and git format-patch | git am?

I sometimes need to cherry-pick a tag with a certain fix into my branch, and used to do so via git cherry-pick tags/myfix This works, but cherry-picking takes an increasingly long time doing "inexact rename detection". My hunch was that this could…
Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
10
votes
2 answers

If I cherry-pick a commit from a branch and then merge the whole branch later what happens to the git history?

So I've got a situation where I only want a particular commit from branchA because other commits in that branch aren't ready to be merged. So if I cherry-pick commitX from branchA into master, and then later merge branchA into master (with some…
user2494770
10
votes
1 answer

How to git cherry-pick a commit with binary files

I am trying to cherry-pick a commit from a different branch that is mostly binary files. It seems it is mostly successful, except for one file where I get the message: warning: Cannot merge binary files: XXXX.so (HEAD vs. d8ef550... Add support for…
Sofia Clover
  • 669
  • 1
  • 7
  • 18
10
votes
1 answer

Why does git cherry-pick not continue?

I am trying to cherry-pick changes from two different working brachnes to each other namely I want to cherry-pick the last 5 commits from branch linear to branch diagonal. git cherry-pick -n -x linear~6..linear As expected there are some merging…
benni
  • 663
  • 1
  • 6
  • 21
10
votes
1 answer

How to cherry pick 2 out of 5 commits of a pull request on GitHub?

I'm new to GitHub. Someone submitted a pull request with 5 commits. 3 of them have a little bug, though, so must wait. How can pick 2 of them for my project?
MaiaVictor
  • 51,090
  • 44
  • 144
  • 286
10
votes
3 answers

git - cherry-pick - HOWTO / WHYTO

Problem: You want to test a feature someone has developed, but it only exists in a remote branch which is woefully out of date. Source How does cherry-pick solve the problem? Why won't I use git am or git apply?
0x90
  • 39,472
  • 36
  • 165
  • 245
9
votes
1 answer

What git hooks can be executed on cherry-pick operation?

I am trying to find a way to check commits when cherry-picking them. Unfortunately, I cannot find a git hook that works with cherry-pick operation. What would be a possible solution to execute a script on cherry-picked commit?
ziemowit141
  • 465
  • 3
  • 18
9
votes
3 answers

what is the difference between a Git-merge and Git-cherry-pick for a specific commit?

Is there a difference between a : git merge and git cherry-pick ? where ''commit-id'' is hash of the commit from my new branch that I want to get into master branch.
Kevin STS
  • 183
  • 2
  • 10
9
votes
2 answers

Which git workflow to use for both product development and product customization

We have been using git-flow for a while for the development of a software framework. We have the masterand development branches in a single repository. Recently, different customers became interested in buying the framework, which requires a…
gehbiszumeis
  • 3,525
  • 4
  • 24
  • 41
9
votes
1 answer

Git cherry pick creates duplicate commits

After cherry-picking some commits from one branch to another branch, i still see commits when a pull request is created later. Say for example, There is a git project which has two branches : Dev , Release. And commit history is in following…
Sri
  • 163
  • 3
  • 12
9
votes
2 answers

How can I tell, from a script, if "git cherry-pick" fails?

If the cherry-pick fails due to a merge conflict, it just returns an exit status of 0. Please don't tell me about --abort. I need to detect, in a script, if the original cherry-pick command fails. Using git version 1.8.3.1 on CentOS 7.2. EDIT: my…
e40
  • 397
  • 1
  • 11
9
votes
3 answers

How do cherry-pick and revert work?

I am trying to understand what merge and rebase do, in terms of set operations in math. In the following, "-" means diff (similar to taking set difference in math, but "A-B" means those in A but not in B and minus those in B not in A), and "+" means…
Tim
  • 1
  • 141
  • 372
  • 590