There's another use I have for git mv
not mentioned above.
Since discovering git add -p
(git add's patch mode; see http://git-scm.com/docs/git-add), I like to use it to review changes as I add them to the index. Thus my workflow becomes (1) work on code, (2) review and add to index, (3) commit.
How does git mv
fit in? If moving a file directly then using git rm
and git add
, all changes get added to the index, and using git diff to view changes is less easy (before committing). Using git mv
, however, adds the new path to the index but not changes made to the file, thus allowing git diff
and git add -p
to work as usual.