Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split file into ours and theirs on conflict

I there a way to get 2 copies of file where first will have remote content and the second with local content

like image 838
IC_ Avatar asked Nov 19 '25 02:11

IC_


1 Answers

I don't think that there is a git option to keep both versions of the file in two copies.

But you can easily acheive this goal with the following commands :

git merge the_branch
git checkout --theirs -- path/to/file ; mv path/to/file path/to/file.theirs
git checkout --ours -- path/to/file ; mv path/to/file path/to/file.ours
git checkout -m -- path/to/file

In the end you have three files :

  • file.theirs, with their version;
  • file.ours, with your version;
  • file, with both versions and conflicts marks.
like image 85
Romain Warnan Avatar answered Nov 20 '25 18:11

Romain Warnan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!