Solve git file conflict using SmartGit: ours vs theirs
Asked Answered
S

1

6

I have a problem here and I don't know why, perhaps I did something wrong. I was working in the same file and other developer was working on it too. He told me that file was pushed to the repository, alright. Before pull the changes I made a commit so my changes was saved and merged with the ones from the other developer but surprise the file is giving me conflicts and I do not what to do for not to loose the other developer changes and mines too. If I open right click => Resolve conflict I got this window:

enter image description here

What each option there means? Which one is more secure and save both changes? (developer and mines)

If I open Conflict solver then I got something like this:

enter image description here

But again I don't know how or what to do in order to maintain both changes, any advice? Help?

Solute answered 26/1, 2015 at 2:8 Comment(0)
A
11

I don't use smartgit, but from the screenshot I can tell the options map to git commands as below:

  1. do nothing, leave the file unresolved. not sure what will happen by choosing this option.
  2. use other developers' changes as git command: git checkout --ours -- FILE
  3. use my changes as git command: git checkout --theirs -- FILE
  4. as you already did, open the conflict resolver.

You may be curious why we use --theirs when using my changes, while --ours when using their changes, this is because you are doing rebase, you are rebasing your original changes on other developers' changes. When you are doing rebase, it's like saving your changes in a temporary file, and moving the HEAD to the latest commit of the remote branch(other developers' changes), and replaying your changes over the current branch, in which case your changes become theirs.

Since you want to save both changes, you should resolve all the conflicts manually, and mark the file as resolved and then continue rebasing.

Aerosphere answered 26/1, 2015 at 10:47 Comment(1)
If you leave the file unresolved and then stage and commit, you commit a file with conflict markers in it. Don't ask me how I found this out. :-/Pelota

© 2022 - 2024 — McMap. All rights reserved.