2

I am new at git and I use windows for git (that's a lot of pain) , and now I'm having a merging trouble with conflict .class file. how should resolve this conflict? I don't really understand about this conflict.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Fugogugo
  • 4,460
  • 10
  • 36
  • 50
  • 1
    1. Read a git tutorial, for example http://gitimmersion.com/ 2. Add *.class to .gitignore file. Compiled files should not be held in a repository. – Rafał Rawicki Feb 02 '12 at 14:43
  • yeah I know about it. I just forgot to ignore it at first. and now it making trouble. how should I overwrite it? – Fugogugo Feb 02 '12 at 14:58
  • 1
    possible duplicate of [Git: Remove a file from the repository without deleting it from the local filesystem](http://stackoverflow.com/questions/1143796/git-remove-a-file-from-the-repository-without-deleting-it-from-the-local-filesy) – Cascabel Feb 02 '12 at 15:47
  • 1
    It's obvious from reading the comments that your problem is that you've committed something you meant to ignore; there are a ton of questions about that. If you care, I put a list of other duplicates on this question yesterday: http://stackoverflow.com/questions/9102408/why-is-git-not-ignoring-dcu-files#comment11433754_9102408 – Cascabel Feb 02 '12 at 15:49

3 Answers3

3

Assuming you're using Java, .class files are just generated machine-code from your compilation. It's not really source code, so there's no conflict resolution that needs to be done here. I would just overwrite the .class files in the target branch.

danyim
  • 1,274
  • 10
  • 27
3

I would not put class files that are generated from your sources into git at all.

You can still delete it locally and then git rm <file> it.

Heiko Rupp
  • 30,426
  • 13
  • 82
  • 119
3

I would say don't even worry about resolving it. Just accept the merge, assuming the class file is the only conflict, using git merge branch -Xtheirs

This will merge as usual but accept all the changes from the branch you're merging from without checking for conflicts.

Alternately you can resolve the conflict manually if it makes you feel better. From this point on there will be no more conflicts with .class files as you've added an entry to .gitignore.

sciritai
  • 3,688
  • 1
  • 17
  • 22
  • Isn't it dangerous to be executing this command? What if his merge has changes that actually need to be reviewed for conflicts? – danyim Feb 02 '12 at 16:03
  • Indeed, hence why I mentioned to only do this if that .class file is the only conflict. – sciritai Feb 02 '12 at 16:12