I know I can get the ours/theirs state by invoking
git checkout --ours/--theirs -- path/to/my/file.txt
but this will overwrite the file in my working tree. How to get the file content of the ours/theirs file state during merge without overwriting the working tree?
Hidden in the docs :
git show :1:file/path # base
git show :2:file/path # ours
git show :3:file/path # theirs
When a merge conflict is triggered because of a merge
action, HEAD
still points to the original commit, and MERGE_HEAD
to the commit trying to be merged in, so :
git show HEAD:file/path # ours
git show MERGE_HEAD:file/path # theirs
will also work, and perhaps be more explicit to the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With