365Git

  1. Search
  2. About
  3. Subscribe
  4. Archive
  5. Random

365Git

Regular small snippets and workflows for Git

My original plan of a post everyday turned out to be unrealistic, but I'll carry on posting as regularly as I can.

Find me @abizern on twitter if you have anything you'd like me to cover.

Newer
Older
  • Quick commit editing with vim

    On Mac OS a and Unix systems Git defaults to using vim as the editor for commits.(I don’t know what the default is on Windows) You can change this, if you like, but for now I’ll just give a couple of tips for using vim — just enough to get by.

    When Git needs a message for an action it will bring up vim in view mode. You can move around using the h(move left), l(move right), k(line up) and j(line down)

    Initial vim window

    But for quick editing, the i key will put you in editing mode where you can type and move around as you would for most editors. When you’ve finished press the esc key to get you out of editing mode.

    vim with commit

    The normal command to save the message and quit is :wq which is bit of a finger twister. An alternative is ZZ which does the same thing, but it’s a much easier key combination to use.

    A final thing. An empty commit message cancels the commit, (or rebase or tag, or whatever action the message is being added for). So if you change your mind just delete the message (the lines starting with the comment character # don’t count). A useful way of doing this is to make sure you’re not in insert mode by pressing the esc key and then using dd which deletes the whole line.

    Tagged: editor git save settings vim day25

    Posted on April 17, 2010 with 4 notes ()

    1. dog--training liked this
    2. 365git posted this

Field Notes Theme. Designed by Manasto Jones. Powered by Tumblr.