Fixed "There was a problem with the editor 'vi'"

穿山甲到底說了什麼發表於2018-12-19

在用git提交的時候 如果不小心打錯了commit -m 'xxx' xxx裡面的內容的話,可以修改,命令是git commit --amend

apple:yunlu_meeting apple$ git commit -m 'delete redu'
//這時候發現打字還沒打完 電腦卡了手賤 多按了回車,鬱悶,於是再一次修改提交資訊
apple:yunlu_meeting apple$ git commit --amend
//WTF,`Vi`編輯器遇到問題,
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
複製程式碼

解決方法是

$ git config --global core.editor /usr/bin/vim -f
複製程式碼

完整的終端列印如下:

apple:yunlu_meeting apple$ git commit --amend
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.
apple:yunlu_meeting apple$ git config --global core.editor  /usr/bin/vim -f 
apple:yunlu_meeting apple$ git commit --amend
[addChat e38cfe4] delete redundant key-values in HBuilder-Hello-Info.plist
 Date: Sat Oct 8 17:48:46 2016 +0800
apple:yunlu_meeting apple$ git push origin addChat:addChat
Counting objects: 198, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (114/114), done.
複製程式碼