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
4
votes
3 answers

How to change the branching point in Git?

Suppose I have the following structure in my git repo: C'---D'---E'---F' (dev) / A---B---C---D---E---F (master) I would like to pull C' into the master branch and change the branching point to C', i.e., I want to turn…
MikeL
  • 2,369
  • 2
  • 24
  • 38
4
votes
1 answer

Git: How to cherry-pick a commit without all previous history

I want to add some specific changes from a specific commit in my current repo to my upstream repo. Running something like this: git push upstream : adds the commit plus all the previous changes Running something like…
Aerodynamika
  • 7,883
  • 16
  • 78
  • 137
4
votes
1 answer

Git for development and live websites

I'm using Git for both my development and live websites, and keep each in their own branches 'dev' and 'master'. When I finish testing on the 'dev' branch I merge my changes back to 'master', however there are several files which I need to keep…
Yarito
  • 161
  • 1
  • 4
4
votes
3 answers

Create a new Git repository from current HEAD, set it as a remote of the original, and mirror future changes to both repositories?

The current repository has commits A -> B -> C ^ | HEAD I want to create a new repository whose master branch begins at commit C (HEAD) of the current repository. C ^ | HEAD Additionally, if a new commit…
Sean Pianka
  • 2,157
  • 2
  • 27
  • 43
4
votes
3 answers

git cherry-pick does not work

I get a strange error: git cherry-pick a0cd8fe fatal: bad revision 'a0cd8fe' Why is that? Note that the branch that a0cd8fe was merged to has been deleted. Is that why I get this error?
leopoodle
  • 2,110
  • 7
  • 24
  • 36
4
votes
1 answer

Git - coworker somehow overwrote my entire commit while resolving a conflict

This is what he says he did: There was a merge conflict so I chose mine. What I'm seeing is that my changes are totally gone. The commit is there, but if I go on GitHub and click 'history' for the file, there's nothing showing that my changes were…
4
votes
2 answers

Merging specific commits without cherry-pick?

So, I've been using git cherry-pick for this but it's getting cumbersome and I wanted to know if there's a simpler way (or another approach). Say I have 3 branches: master (stable, candidate for production), develop (working branch) and…
imiric
  • 8,315
  • 4
  • 35
  • 39
3
votes
1 answer

Merged conflict cherry-picks still show as not merged in git cherry output

tldr; Cherry-picking commit into another branch where a conflict exists, requiring manual resolution in a new branch, causes the original commit id to not show in the git -cherry -v output. How can we get the commit id to show so we know the fix…
cminus
  • 1,163
  • 12
  • 25
3
votes
1 answer

After deletion of a local branch in git, will I be able to cherry-pick commits from the deleted branch by their IDs?

If I have a local branch in git with commits A, B, C, D, E and I choose to delete it using git branch -D myBranch but I save the commit IDs before deleting, will I be able to cherry-pick some of these commits to another branch by their IDs…
3
votes
1 answer

Using git rebase interactive to orchestrate series of git cherry-pick?

git cherry-pick allows simple merges to be cherry-picked simply by indicating which of the merge parents should be used as the baseline. For example: git cherry-pick -m 1 1234abcdef I have a bunch of commits that I want to cherry pick, a few of…
Brad
  • 3,190
  • 1
  • 22
  • 36
3
votes
1 answer

How to skip inexact rename detection with git cherry-pick

I have a about 10 commits I need to cherry pick from an old branch to a current branch on a large repo. Every time I run the cherry-pick command I get the following: $ git cherry-pick -x 11a77a55bf Performing inexact rename detection: 0%…
TTT
  • 22,611
  • 8
  • 63
  • 69
3
votes
1 answer

How do I make a PR from a forked repo, for only certain files, but all commits on them?

tl;dr I've forked a repo and made many commits on many files, all on the master branch. Now I want to create a pull request for all commits on select files, to send back to the original repo's author. For example, I want to send back some…
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
3
votes
1 answer

Cherry Pick Problem in Visual Studio 2019

I just ran into a problem caused by cherry picking within VS2019 which caused me to have to blow away and recreate both my local and github repositories. No big deal as the code was reasonably stable and I'm not co-developing it with anyone. But I'd…
Mark Olbert
  • 6,584
  • 9
  • 35
  • 69
3
votes
1 answer

Merge bug fixes patches from release branch to master branch

I have one master branch where i am pushing my latest development. Now at some point, I do release and create new branch called release1 from master branch. Now i am doing new development on master branch Meantime other team also perform some bug…
Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
3
votes
1 answer

Can you cherry-pick a hunk or hunks from within a git commit?

When I do stage commits in my workspace I usually use the -p option to go through each hunk of the changes. I find this useful to confirm my changes and as a check on typos and other silly errors. I usually rebase in my open source development work…
Lucas Roberts
  • 1,252
  • 14
  • 17