How can I show the files git checkout adds/modifies/deletes in my working directory when I switch branches?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With