+1 vote
1 view
in Devops and Agile by (20k points)

I made some changes in my master branch and want to bring those upstream. when I cherry-pick the following commits however I get stuck on fd9f578 where git says:

$ git cherry-pick fd9f578

fatal: Commit fd9f57850f6b94b7906e5bbe51a0d75bf638c74d is a merge but no -m option was given.

What is git trying to tell me and is cherry-pick the right thing to be using here? The master branch does include changes to files which have been modified in the upstream branch, so I'm sure there will be some merge conflicts but those aren't too bad to straighten out. I know which changes are needed where.

These are the commits I want to bring upstream.

e7d4cff added some comments...

23e6d2a moved static strings...

44cc65a incorporated test ...

40b83d5 whoops delete whitspace...

24f8a50 implemented global.c...

43651c3 cleaned up ...

068b2fe cleaned up version.c ...

fd9f578 Merge branch 'master' of ssh://extgit/git/sessions_common

4172caa cleaned up comments in sessions.c ...

1 Answer

0 votes
by (28.4k points)

Let us assume that you are on branch X, and you want to cherry-pick the commits Y..Z.

  1. git checkout -b tempZ Z
  2. git rebase Y
  3. git checkout -b newX X
  4. git cherry-pick Y..tempZ
  5. (optional) git branch -D tempZ

Let us discuss what these commands will do. First,  a branch tempZ based on Z will be created, but with the history from Y onward linearized, and then cherry-pick that onto a copy of X called newX. (It's safer to do this on a new branch rather than to mutate X.) Of course there might be conflicts in step 4, which you'll have to resolve in the traditional way (cherry-pick works very much like rebase in that respect). Finally it deletes the temporary tempZ branch.

Note that if step 2 gives the message "Current branch tempZ is up to date", then Y..Z was already linear, so just ignore that message and proceed with steps 3 onward.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...