Wednesday·10·August·2011
git $something -p //at 16:09 //by abe
git add -p
is one of my favourite git features. It lets you selectively
add the local changes hunk by hunk to the staging area. This is
especially nice if you want to commit one change in a file, but not a
second one, you also already did.
Recently I noticed that
you can also selectively revert changes already in the staging area
using git reset -p HEAD
. The user interface is exactly
the same as for git add -p
.
Today I discovered another selective undo in git by just trying it out
of curiosity if that works, too: Undoing local changes selectively
using git checkout -p
. Maybe less useful than those
mentioned above, but nevertheless most times quicker than firing up
your favourite editor and undoing the changes manually.
Another nice git feature which I discovered by accidentially using it
(this time even unwittingly) is git checkout -
which
behaves like cd -
, just for branches instead of
directories, i.e. it switches back to the previously checked out
branch. Very useful for quickly changing between two branches again
and again.
Tagged as: CLI, git, HTH, identi.ca, UUUCO
// write a comment // comments off