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
9
votes
2 answers

Cherry-pick commits to a particular folder of git repo from other repo

I am very much familiar with git cherry-pick. Currently i am trying to cherry-pick few commits from other git repository. Scenario is as below: A -> git repo ("A/foo/B" where B is a directory inside foo) B -> git repo My intention is to…
love
  • 1,000
  • 2
  • 16
  • 35
9
votes
2 answers

Why does this cherry pick result in a merge conflict

Edit: I added some Information I thought to be unnecessary, but is not. I have two branches, A and B. After making three commits in A that changes file.c I want to cherry-pick them into B, there is also a file.h which was changed in A~1 > git…
crunsher
  • 377
  • 1
  • 3
  • 7
9
votes
4 answers

Merge old git commit with HEAD at master

I made some mistakes when merging commits of my colleagues. Now, we have discovered it and we need to apply old commit again, to choose manually the changes in the files. The situation looks like this: A--\ /--F--\ C--D--E H--I B--/^…
Pavel S.
  • 11,892
  • 18
  • 75
  • 113
8
votes
1 answer

Why doesn't `git cherry-pick` (without `--no-commit`) run my post-commit hook?

How can I trigger a post-commit hook with the command git cherry-pick ? What I've tried: I tried the command git commit -m '...' . It triggered the post-commit hook normally. In the githooks document, there are no hooks related to…
LongFeida
  • 83
  • 1
  • 4
8
votes
2 answers

Figure out dependencies of a commit we try to cherry pick

Assume something like the following: HEAD/master | A<--B<--C<--D<--E<--F<--G<--J ^ official Where official is a branch. I wanted to cherry-pick 2 commits to official…
Jim
  • 18,826
  • 34
  • 135
  • 254
8
votes
1 answer

What is the .git/sequencer directory?

I found a directory named .git/sequencer Here is its contents: $ ls head todo $ cat head d7d462cf3c0896aa09b3dec020cb21d4c4407d91 $ cat todo pick d7d462c Initailise repository pick b88c8bb bash_funcs: add quote_args() These pick lines make it…
Tom Hale
  • 40,825
  • 36
  • 187
  • 242
8
votes
2 answers

git cherry-pick a diff between commits without common history?

Scenario: A repository with totally disconnected pieces of history. E.g. from different remotes that have no common git history. (This typically occurs in scenarios with git subtree.) Is it possible to cherry-pick the diff between these two commits,…
donquixote
  • 4,877
  • 3
  • 31
  • 54
8
votes
2 answers

Git pull on non-working branch without switching

We have a development branch which is our master and a separate maintenance branch. I frequently have to cherry-pick commits from the master to the maintenance or vice-versa when I fix bugs. Normally I accomplish this by performing the following…
John Brooks
  • 73
  • 1
  • 4
8
votes
2 answers

Will cherry-picking on a tag affect the latter?

While doing a release, I checked out the previously released tag and cherry-picked the new items (using git cherry-pick ) into it. Then, I created a new tag using git tag . Will this affect the old tag I cherry-picked the…
Stranger
  • 10,332
  • 18
  • 78
  • 115
7
votes
3 answers

Git cherry-pick - How to display changes without actually doing anything

Is there any way to display changes that would be applied by the 'git cherry-pick ' before actually doing anything? I would like to see a 'git diff' type of list of changes that would be done by the command without actually doing the changes or…
mikkom
  • 3,521
  • 5
  • 25
  • 39
7
votes
3 answers

What is the equivalent in TFVC of git cherry-pick

I'm sorry for my question but I'm TFS noob user, what is the equivalent in TFVC (Team Foundation Version Control) of git cherry-pick?
slacky82
  • 342
  • 4
  • 11
7
votes
1 answer

Why does git's cherry picking with more than one commit fail?

I try to merge two repos, yielding a flat (aka interleaved) history. I do this along the lines of https://stackoverflow.com/a/14839653/188108, under "History rewrite:". The two branches to merge are in "master" and "src/master". Then, I write: $…
Torsten Bronger
  • 9,899
  • 7
  • 34
  • 41
7
votes
1 answer

Cherry pick only commits that touch a particular file

What is a concise way to request "cherry pick from another branch only the commits that touch a particular file"? i.e. the command git log ..other-branch afile gives a list of unmerged commits in other-branch that touch "afile"; how can I request…
gcbenison
  • 11,723
  • 4
  • 44
  • 82
6
votes
1 answer

what does git cherry-pick {commit-hash} do?

Given that I have 3 commits in order c1 + print("A") c2 + print("B") c3 + print("C") then I checkout a new branch at c1. git checkout -b br c1 then I cherry-pick c3. git cherry-pick c3. what I want is the file has print("A") print("C") -- I…
zhihuifan
  • 1,093
  • 2
  • 16
  • 30
6
votes
1 answer

git compare two branches which contains some common commit with different hash

Context : We are a team of programmer who work on a project with severals branches : Master, Release, Develop Sometimes we need to fix a bug on release, and we need to report this fix on develop, to report our bug fix we use : git cherry-pick…