Trying to learn GitHub at the moment and doing this Git essentials tutorial over at nettuts. I'm on the lesson about making commits.
The teacher types git commit
and it opens VIM as his editor (I'd also like to know how to make it open up in Sublime Text 2 instead) anyways it opens in VIM and I add in 1 line saying this is my first commit and hit save.
Next it then prompts me to save the output to the desktop, something I did not see in his screencast. Now I'm still in VIM and not sure how to get back to 'normal' terminal :(
I couldn't figure it out so I just exited the terminal and relaunched it, did git commit again and had some warning messages about duplicates! Not sure if I need to (E)edit
anyways or (A)abort
.
git status
vim
message when I reopen terminal and do git commit again
This question is related to
git
vim
terminal
command-line-interface
commit
not really the answer to the VIM problem but you could use the command line to also enter the commit message:
git commit -m "This is the first commit"
This is in answer to your question...
I'd also like to know how to make it open up in Sublime Text 2 instead
For Windows:
git config --global core.editor "'C:/Program Files/Sublime Text 2/sublime_text.exe'"
Check that the path for sublime_text.exe
is correct and adjust if needed.
For Mac/Linux:
git config --global core.editor "subl -n -w"
If you get an error message such as:
error: There was a problem with the editor 'subl -n -w'.
Create the alias for subl
sudo ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
Again check that the path matches for your machine.
For Sublime Text simply save cmd S
and close the window cmd W
to return to git.
Simply doing the vim "save and quit" command :wq
should do the trick.
In order to have Git open it in another editor, you need to change the Git core.editor
setting to a command which runs the editor you want.
git config --global core.editor "command to start sublime text 2"
You need to return to normal mode and save the commit message with either
<Esc>:wq
or
<Esc>:x
or
<Esc>ZZ
The Esc key returns you from insert mode to normal mode. The :wq, :x or ZZ sequence writes the changes and exits the editor.
Source: Stackoverflow.com