Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show changes git checkout makes to the working directory

Tags:

git

How can I show the files git checkout adds/modifies/deletes in my working directory when I switch branches?

like image 610
spiffytech Avatar asked Jan 19 '12 17:01

spiffytech


1 Answers

I don't believe that there is any "verbose"-like option you can add to the git checkout <branch> command to output this information. However, after the successful checkout, you can run:

git diff --name-status HEAD@{1} HEAD

The output from that command will indicate by the letter in the first column whether the file was deleted (D), added (A), modified (M), etc. with respect to the previous commit you were at.

As a possibly helpful additional point, note that when you switch branches, git will attempt to preserve local modifications to your files that haven't yet been committed. If this switch of branch wouldn't clobber those changes, they will be indicated immediately on the terminal immediately after the checkout such as:

$ git checkout other-branch
M foo.c
M foo.h
like image 116
Mark Longair Avatar answered Oct 12 '22 14:10

Mark Longair