0

I have to get some changes from a developer. Because I do not want to perform manual merging I do:

git pull -s ours origin developers_branch

The problem is sometimes I need all changes in a particular file (i.e. to do merging if there are conflicts).

So the question is how to obtain all changes (ignoring emerging conflicts in my favor) except for a particular file.

Christopher
  • 42,720
  • 11
  • 81
  • 99
Agent Coop
  • 392
  • 4
  • 12
  • How would you determine which conflicts you should see and which you shouldn't? – Christopher Aug 22 '12 at 10:18
  • I am interested in particular changes. For instance our designer changes CSS styles in the file main.css. I need those changes because my ongoing work depends on them. In addition I would like to get other changes without merging so I wont probably get any trouble in the future.The oftener you merge the less problems you have. – Agent Coop Aug 22 '12 at 11:12
  • In that particular case, the designer could stage just the CSS files, commit and push – davids Aug 22 '12 at 11:15
  • 1
    It is sometimes true "the more often you merge, the fewer problems you have". That doesn't apply as neatly to merges with `-s ours`. You're abandoning other contributor's changes when conflicts arise. Unless your workflow takes that into account, it'll cause trouble at integration time and might result in broken code. – Christopher Aug 22 '12 at 12:34

1 Answers1

0

Just use --no-commit option, then make appropriate changes (undo changes in the file, etc), then git commit.

Also, worth to mention a better approach: split the changes in different commits/branches: which require merge and which don't require. After it you could do merges easily.

kan
  • 28,279
  • 7
  • 71
  • 101
  • Would this work? Does the `-s ours` merge strategy abandon the changes *after* `--no-commit` would operate? – Christopher Aug 22 '12 at 12:31
  • Oh, I missed this part. You can omit `-s ours`, merge all, and before the commit revert all changes except in the file. – kan Aug 22 '12 at 12:34
  • @Christopher This is answer which describes this approach step-by-step http://stackoverflow.com/a/7292109/438742 – kan Aug 22 '12 at 12:41