Tuesday, March 08, 2011


What I learned about git today: reverting, ignoring, diffing, and vimming

I learned a few things about git today:
  1. I wanted to see what I'd added to the index, but not committed. There may well be a better way to do it, but here are the two commands I discovered and aliased:
        di = diff-index --color=auto --cached --patch --relative HEAD    # shows the actual differences
        dfi = diff-index --color=auto --cached --name-only --relative HEAD   # shows just the files which are changed
  2. I wanted to remove changes from index. The Git Book has an excellent page on all manner of undoing. Specifically, I needed the "git reset" command to revert staged but uncommitted changes.
  3. Git kept telling listing files whose mode had been changes in the list of diffs. While those are technically diffs, I didn't care. I found the solution on Stack Overflow. "git config core.filemode false" changes the config with a repo to ignore file mode changes.
  4. I've long enjoyed seeing side-by-side diffs of pending CVS changes in vim. I've been using the CVSMenu plugin for as long as I can remember. Of course, it doesn't work with git, but there's an even cooler plugin for vim these days, VCS Command, which gives you similar functionality for many version control systems, including git.

Nice article with pretty pictures describing how git reset works: http://progit.org/2011/07/11/reset.html Also has some nice cheat sheets.

The comments include this gem for remembering what the different modes of git reset do:

--soft -> git uncommit
--mixed -> git unadd
--hard -> git undo
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?