I've noticed that while working on one or two tickets, if I step away, I'm not sure what I worked on, what changed, etcetera.
Is there a way to see the changes made for a given file before git add and then git commit?
The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
You're looking for
git diff --staged
Depending on your exact situation, there are three useful ways to use git diff
:
git diff [filename]
--staged
does exactly the same thing, use what you like):git diff --cached [filename]
git diff HEAD [filename]
git diff
works recursively on directories, and if no paths are given, it shows all changes.
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