4

I am trying to merge two repositories, and there are only a couple of "real" conflicts, but there are about 70 file conflicts of "Both added". When viewing a git diff, however, it only shows file mode changed.

What would be the best way to mass-accept the current file mode and ignore the incoming file mode?

A little background: These 2 repositories are of the same code, but one has been tracked through SVN, so doesn't have a history. I'm using git-svn to track it now and merge it with the current git repository.

The incoming conflicts on merge appear as: CONFLICT (add/add): Merge conflict in framework/file/name.php Automatic merge failed; fix conflicts and then commit the result.

Git status shows: both added: framework/file/name.php

If I use the git mergetool, it does not show any conflicts. Going through each file using this method takes a very long time.

Highway of Life
  • 22,803
  • 16
  • 52
  • 80

2 Answers2

5

So after trying all the various merge strategies, and determining that I needed to take the file mode from the repository, discarding the local file mode, the best solution I came up was to use: git checkout --theirs <remote/branch> -- path for the filemode changes, and used git mergetool for the code conflict resolution. Using git diff, I could see which files were filemode changes, and which were file code changes. git merge uses --recursive -Xours as the default merge strategy.

There is a git config variable: core.fileMode that can ignore file mode changes. See: How do I make Git ignore file mode (chmod) changes?

Community
  • 1
  • 1
Highway of Life
  • 22,803
  • 16
  • 52
  • 80
1

How about git merge -Xours branchToMergeIn? It will merge the two and give preference to your current branch. Never tried it with mode changes, but should do the trick...

edited with jeffromi's merge strategy.

Andy
  • 44,610
  • 13
  • 70
  • 69
  • There were other real conflicts that needed to be resolved, and some code that needed to be pulled in. By running `git merge -s ours remote/branch` it said: "Merge made by ours", yet running git status shows nothing changed... no new commits, no conflicts. Nothing. – Highway of Life Jul 26 '11 at 21:38
  • So it never created a merge commit? You'd have to look at `git log` to see the commits, `git status` won't show you any commits. If you want to selectively merge somethings, and not others, I don't think you have much of a choice about going through each file... – Andy Jul 26 '11 at 21:46
  • When tracking master it would show commits ahead of master, I forgot to track master, so after doing that, it shows it's ahead by 301 commits. However, when running git show on the merge commit, it's not showing any diff or file changes. So not sure on that one. Thanks for your help so far. :) – Highway of Life Jul 26 '11 at 22:08
  • Actually, it might have worked... I see the commits in the history, although the merge doesn't show a diff, I'm not sure it should. Now I just need to find a way to see if the changes were applied as they should have been. – Highway of Life Jul 26 '11 at 22:10
  • @Highway: By default, `git show` (and similar commands) do not print diffs for merge commits. To see the diff, try `git show -c`. Additionally, `gitk` by default does show merge diffs. – Cascabel Jul 27 '11 at 07:52
  • 2
    Also, note that `git merge -s ours` means "record a merge, but use the content from the current branch" - it completely ignores the other branch's content. If you want to just resolve conflicts in favor of the current branch, while doing all non-conflicting merges normally, you want `git merge -Xours`. See [`man git-merge`, under merge strategies](http://www.kernel.org/pub/software/scm/git/docs/git-merge.html#_merge_strategies). – Cascabel Jul 27 '11 at 07:55