Cant commit after starting a merge in Sourcetree

后端 未结 5 1272
后悔当初
后悔当初 2020-12-28 13:43

When trying to commit after a merge I\'m getting this error message:

\"fatal: You are in the middle of a merge -- cannot amend.\"

<
5条回答
  •  有刺的猬
    2020-12-28 14:09

    If you are trying to amend on a previous commit and you know there will be merge conflicts then force push the changes (if you are sure that you want your current changes to override remote changes).

    First commit:
    
     1. git add test.txt
     2. git commit -m "some changes"
     3. git push
    
    Second commit after some changes in same file which will result in merge conflict and we know we want only the latest changes that we did in this file:
    
    1. git add test.txt
    2. git commit --amend
    3. git push -f
    

    Otherwise, we might get stuck in merge and commit loop.

提交回复
热议问题