2014-03-27 173 views
18

失去了我笨拙的打字員,我不使用vi/vim的非常頻繁的消息,但我不使用它的提交信息。但是,如果在編輯(而不是:wq:Wq,比如說)提交信息你輸入一個錯誤的命令,當你正確地收出提交信息在VIM與:wq:x,你會得到這樣的:git的承諾由六

error: There was a problem with the editor 'vi'. 
Please supply the message using either -m or -F option. 

常,像:W這樣的錯誤命令是沒有問題的 - vim只是忽略它,你可以繼續使用這個文件並保存它,但是當我錯誤地輸入git commit消息時,我已經不可撤銷地丟失了提交消息。

這是怎麼回事,我該如何解決? (通過自制使用GIT 1.9.1,VIM 7.3與OS X 10.9封裝)

+0

我解決這個問題和其他問題是,並一直在切換到'nano'。 – Darkhogg

回答

26

你應該設置vim不要從shell中分離,並且處於前臺。你可以用下面的命令做到:

git config --global core.editor vim -f 

從男人:

-f   Foreground. For the GUI version, Vim will not fork and detach from the shell it 
       was started in. On the Amiga, Vim is not restarted to open a new window. This 
       option should be used when Vim is executed by a program that will wait for the 
       edit session to finish (e.g. mail). On the Amiga the ":sh" and ":!" commands 
       will not work. 
+0

這確實修復了它! – xbonez

-1

如在幾個職位VIM提到與零以外的退出代碼退出。您可以通過編輯的git明確地設置爲完整的Vim路徑解決它:

git config --global core.editor /usr/bin/vim 

如果我沒有記錯我通過安裝VIM家釀修復問題。確保你的路徑設置正確然後。

+0

我其實剛剛檢查了這個 - 打開vim,輸入了一個錯誤的命令,然後正確輸入了':wq',並且檢查了退出代碼('echo $?'),並且退出代碼爲0. – xbonez