Git - How to close commit editor?

2019-01-29 15:19发布

I'm new to git and learning from a PDF. I just executed a command $ git commit and it opens a new editor. But I'm trying to close that new commit editor. How to do this? I'm using git on windows.

6条回答
虎瘦雄心在
2楼-- · 2019-01-29 15:56

Better yet, configure the editor to something you are comfortable with (gedit as an example):

git config --global core.editor "gedit"

You can read the current configuration like this:

git config core.editor

You can also add the commit message from the command line.

git commit -m "blablabla"

and the editor will not be opened in the first place.

查看更多
家丑人穷心不美
3楼-- · 2019-01-29 15:56

As an alternative to 'save & quit', you can use git-commit's function git-commit-commit, by default bound to C-c C-c. It will save the file and close it. Afterwards, you still have to close emacs with C-x C-c, as mentioned before. I am currently trying to find out how to make emacs quit automatically.

查看更多
Ridiculous、
4楼-- · 2019-01-29 16:01

After writing commit message, just press Esc Button and then write :wq or :wq! and then Enter to close the unix file.

查看更多
Animai°情兽
5楼-- · 2019-01-29 16:02

I had this problem I riceive a a > like prompt and I couldn't commit. I change the " in the comment for ' and it works.

I hope this help someone!

查看更多
可以哭但决不认输i
6楼-- · 2019-01-29 16:08

Save the file in the editor. If it's Emacs: CTRLX CTRLS to save then CTRLX CTRLC to quit or if it's vi: :wq

Press esc first to get out from editing. (in windows/vi)

查看更多
欢心
7楼-- · 2019-01-29 16:09

Had troubles as well. On Linux I used Ctrl+X (and Y to confirm) and then I was back on the shell ready to pull/push.

On Windows GIT Bash Ctrl+X would do nothing and found out it works quite like vi/vim. Press i to enter inline insert mode. Type the description at the very top, press esc to exit insert mode, then type :x! (now the cursor is at the bottom) and hit enter to save and exit.

If typing :q! instead, will exit the editor without saving (and commit will be aborted)

查看更多
登录 后发表回答