Git merge left HEAD marks in my files

前端 未结 5 813
旧时难觅i
旧时难觅i 2020-11-22 15:26

I tried to merge a file in the command line using Git, when an error message appeared telling me the merge was aborted.

I thought that was the end of it, but then I

5条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 15:49

    Absolutely start with 'git status' to see what you've got. If you aborted a merge (or had a merge aborted) and you've got conflicted files in the working directory then something went wrong. The Git status will tell you where you are. After that, you have a number of options. You should resolve the merge commit either by-hand, which can be challenging, or using a tool as:

    git mergetool
    

    The merge tool will work if your files are listed as needing a merge.

    You can also perform one of:

    git checkout --ours -- /path/to/conflicted-file       # this is probably the one you want
    git checkout --theirs -- /path/to/conflicted-file
    

    You can see the different versions using the :1:filename syntax. See here for an explanation. But all of the above assumes that 'git status' shows the files as needing a merge.

    Finally, you always have the option of:

    git reset --hard   # sounds like --hard is what you need but check other options
    

提交回复
热议问题