9

It's kind of like I want to cherry pick all commits from the branch except for one, but I'd like to do that in one command...

• We cut a release, which creates a branch

• The release changes the version number in all our poms, on the branch to one number, and on master to a different number

• I've committed a number of other changes to the branch and want to copy those changes back onto master

• I've merged the branch back into master, which brought the code changes but also the version number changes, creating conflicts in every pom

Is there any easy way for me to revert all the pom files to their pre-merge content and then commit that as the result of the merge?

Graham Lea
  • 5,797
  • 3
  • 40
  • 55
  • If your situation is that you want to merge but leave out of the merge any files that conflict, see [Can I merge only non-conflicting changes in Git?](http://stackoverflow.com/questions/12572530/git-merge-ignoring-conflicts) – Graham Lea Nov 03 '12 at 11:14
  • There is a better solution. Use my merge driver and you dont have to do anything :-) have a look at my answer: http://stackoverflow.com/a/26866992 – Sven Oppermann Mar 20 '15 at 01:30

1 Answers1

14

Here's what I'd suggest doing. First, do a regular merge but don't commit it:

git checkout master
git merge --no-commit <branch>

then, revert all of the pom files:

for file in $(find . -name 'pom.xml'); do git checkout HEAD "$file"; done

then you should be able to commit the final result:

git commit
Graham Lea
  • 5,797
  • 3
  • 40
  • 55
Amber
  • 507,862
  • 82
  • 626
  • 550
  • Worked great. Thanks! The log graph looks far better than a cherry-pick. There is still a bunch of untracked .orig and .BACKUP files, but getting rid of them is a different matter. – Graham Lea Nov 01 '12 at 03:21