I want to see diff on files that I've added to commit (git add something). I can do this:
git diff HEAD `git status -s | grep ^M | cut -c 4-` Is there a shorter way?
simply typing git status gives you a list of staged files, a list of modified yet unstaged files, and a list of untracked files. @houtanb, git status shows you a diff. (It doesn't show you all staged files).
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit.
You can use git diff --staged (or git diff --cached) to see the diff that will be used when committing.
From the manpage:
git diff [--options] --cached [<commit>] [--] [<path>...]
This form is to view the changes you staged for the next commit relative to the named<commit>. Typically you would want comparison with the latest commit, so if you do not give<commit>, it defaults toHEAD. IfHEADdoes not exist (e.g. unborned branches) and<commit>is not given, it shows all staged changes.--stagedis a synonym of--cached.
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