Tuesday, March 08, 2011
What I learned about git today: reverting, ignoring, diffing, and vimming
I learned a few things about git today:
- 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
- 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.
- 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.
- 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.
Comments:
<< Home
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
The comments include this gem for remembering what the different modes of git reset do:
--soft -> git uncommit
--mixed -> git unadd
--hard -> git undo
<< Home