Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solve git file conflict using SmartGit: ours vs theirs

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?

like image 989
ReynierPM Avatar asked Feb 11 '23 02:02

ReynierPM


1 Answers

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.

like image 125
neevek Avatar answered Feb 14 '23 08:02

neevek