場景:
pull代碼後衝突:
解決衝突後提交代碼報錯:
執行 commit報錯:
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm ’
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
解決方法:
If you have fixed the conflicts you need to add the files to the stage with git add [filename], then commit as normal.
就是你手動修改git提示有錯誤的文件,修改之後,添加有衝突的文件: git add [被修改的衝突文件], 最後,按照普通提交那樣,提交有衝突的問題: git commit [修改後的衝突文件] -m “註釋內容”
即: 先執行 add命令,在執行commit命令
還有一種方法:
# 在命令上加-f參數
git pull -f