1

I'm trying to bring commits from master which fixed a ton of newline issues into a feature branch without having to manually deal with all the conflicts induced by those newline changes.

We made a few commits in the master branch to fix some messed up newline characters. These commits touched many files in the repository. Now I'd like to bring those changes into a feature branch myfeature which has its own commits apart from what exist in master. If we just do

$ git checkout myfeature
$ git merge master

we get conflicts because Git thinks that every line in master is different from every line in myfeature, which is true. If we try to use

$ git merge -s recursive -Xignore-space-at-eol master

as described in this SO question, Git will use the newlines from myfeature for any line where there were no substantial changes in master, which is the opposite from what I want.

Is there a way to merge master into myfeature getting the updated newlines but without having to manage conflicts manually?

Community
  • 1
  • 1
DanielSank
  • 3,303
  • 3
  • 24
  • 42
  • why don’t you just merge the other direction if the command then does what you want? – Chronial Dec 11 '14 at 04:32
  • @Chronial: Merging the other direction puts unfinished work from `myfeature` into `master`, which is definitely no bueno. – DanielSank Dec 11 '14 at 05:10

1 Answers1

1

More a comment, but too long: Just merge the other direction and name the branches the way you like it:

git branch tmpbranch master
git checkout tmpbranch
git merge -s recursive -Xignore-space-at-eol -m "my merge message" myfeature
git branch -f myfeature tmpbranch
git checkout myfeature
git branch -D tmpbranch

Note that git records the direction of the merge, which will be incorrect after this. But I have never seen a tool actually use that information and people constantly mess this up anyways, so this shouldn’t be problem.

Chronial
  • 66,706
  • 14
  • 93
  • 99
  • This is definitely a simple and probably good enough approach. I'll try this tomorrow at work and see if it works nice. Thanks. – DanielSank Dec 11 '14 at 06:11
  • I wound up making a series of blunders and screwing everything up. I haven't forgotten about this post though. Since I owe it to the Universe to evaluate this method carefully I'll mock up the situation and try it. – DanielSank Jan 16 '15 at 20:01
  • Do you have the branch names reversed in the first line of code? – DanielSank Jan 17 '15 at 20:11
  • This doesn't seem to work. When I do the merge I get the fixed newlines only in files which have not been changed in the feature branch. – DanielSank Jan 17 '15 at 20:28