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

前端 未结 18 1337
长情又很酷
长情又很酷 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:24

    If you just want to ditch the whole cherry-picking and commit files in whatever sets you want,

    git reset --soft <ID-OF-THE-LAST-COMMIT>
    

    gets you there.

    What soft reset does is it moves the pointer pointing to current HEAD to the commit(ish) you gave but does not alter the files. Hard reset would move the pointer and also revert all files to the state in that commit(ish). This means with soft reset you can clear the merge status but keep the changes to actual files and then commit or reset them each individually per your liking.

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

    For myself this happened in SourceTree when I tried to commit a merge before resolving all of the files. I then marked the last file resolved and yet it still gave me this error when trying to commit. I closed SourceTree and reopened it, and then it committed fine.

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

    After reading all comments. this was my resolution:
    I had to "Add" it again than commit:

    $ git commit -i -m support.html "doit once for all" [master 18ea92e] support.html
    
    0 讨论(0)
  • 2020-12-07 07:25
    git commit -am 'Conflicts resolved'
    

    This worked for me. You can try this also.

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

    Your merge stopped in the middle of the action. You should add your files, and then 'git commit':

    git add file_1.php file_2.php file_3.php git commit

    Cheers

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

    You can use git commit -i for most cases but in case it doesn't work

    You need to do git commit -m "your_merge_message". During a merge conflict you cannot merge one single file so you need to

    1. Stage only the conflicted file ( git add your_file.txt )
    2. git commit -m "your_merge_message"
    0 讨论(0)
提交回复
热议问题