Git error on commit after merge - fatal: cannot do a partial commit during a merge

前端 未结 18 1338
长情又很酷
长情又很酷 2020-12-07 07:15

I ran a git pull that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also).

When I commit the resolved file

相关标签:
18条回答
  • 2020-12-07 07:34

    Looks like you missed -m for commit command

    0 讨论(0)
  • 2020-12-07 07:35
    1. go to your project directory
      1. display hidden files (.git folder will appear)
      2. open .git folder
      3. remove MERGE_HEAD
      4. commit again
      5. if git told you that git is locked go back to .git folder and remove index.lock
      6. commit again everything will work fine this time .
    0 讨论(0)
  • 2020-12-07 07:40

    You probably got a conflict in something that you haven't staged for commit. git won't let you commit things independently (because it's all part of the merge, I guess), so you need to git add that file and then git commit -m "Merge conflict resolution". The -i flag for git commit does the add for you.

    0 讨论(0)
  • 2020-12-07 07:40

    As the error message says you cannot do a partial commit after a merge. Instead of committing just file.php you should commit all the changes.

    This should work.

    git commit -m "Fixing merge" 
    
    0 讨论(0)
  • 2020-12-07 07:41

    If you are using Source tree or other GUI ensure all files are checked (after merge).

    0 讨论(0)
  • 2020-12-07 07:47

    git commit -i -m 'merge message' didn't work for me. It said:

    fatal: No paths with --include/--only does not make sense.

    FWIW, I got here via this related question because I was getting this message:

    fatal: You have not concluded your merge (MERGE_HEAD exists).

    I also tried mergetool, which said No files need merging. Very confusing! So the MERGE_HEAD is not in a file that needs merging-??

    Finally, I used this trick to add only the modified files (did not want to add all the files in my tree, since I have some I want to keep untracked):

    git ls-files -m | xargs git add

    Then I was finally (!) able to commit and push up. It sure would be nice if git gave you better hints about what to do in these situations.

    0 讨论(0)
提交回复
热议问题