Using git commit -a with vim

前端 未结 6 1661
攒了一身酷
攒了一身酷 2020-12-22 14:52

I\'m new with git, so I decided to learn git using the tutorials of github. The third chapter said:

\"For this first example we’ll modify the README

相关标签:
6条回答
  • 2020-12-22 15:22

    See this thread for an explanation: VIM for Windows - What do I type to save and exit from a file?

    As I wrote there: to learn Vimming, you could use one of the quick reference cards:

    • http://bullium.com/support/vim.html
    • http://tnerual.eriogerg.free.fr/vim.html

    Also note How can I set up an editor to work with Git on Windows? if you're not comfortable in using Vim but want to use another editor for your commit messages.

    If your commit message is not too long, you could also type

    git commit -a -m "your message here"
    
    0 讨论(0)
  • 2020-12-22 15:23

    To exit hitting :q will let you quit.

    If you want to quit without saving you can hit :q!

    A google search on "vim cheatsheet" can provide you with a reference you should print out with a collection of quick shortcuts.

    http://www.fprintf.net/vimCheatSheet.html

    0 讨论(0)
  • 2020-12-22 15:24

    The better question is: How do I interrupt the commit when I quit vim?

    There are 2 ways:

    1. :cq or :cquit
    2. Delete all lines of the commit message, including comments, and then :wq

    Either way will give git an error code, so it will not proceed with the commit. This is particularly useful with git commit --amend.

    0 讨论(0)
  • 2020-12-22 15:29

    Instead of trying to learn vim, use a different easier editor (like nano, for example). As much as I like vim, I do not think using it in this case is the solution. It takes dedication and time to master it.

    git config core.editor "nano"
    
    0 讨论(0)
  • 2020-12-22 15:39
    1. In vim, you save a file with :wEnter while in the normal mode (you get to the normal mode by pressing Esc).
    2. You close your file with :q while in the normal mode.

    You can combine both these actions and do Esc:wqEnter to save the commit and quit vim.

    As an alternate to the above, you can also press ZZ while in the normal mode, which will save the file and exit vim. This is also easier for some people as it's the same key pressed twice.

    0 讨论(0)
  • 2020-12-22 15:44

    Try ZZ to save and close. Here is a bit more info on using vim with Git

    0 讨论(0)
提交回复
热议问题