The Git snippet collection contains a variety of short tips and tricks for all currently maintained versions of git. It includes most commonly-used commands and covers various use-cases in the form of simplified documentation, complete with multiple examples.
Short code snippets for all your development needs.
View differences in changes
Displays differences between staged or unstaged changes and the last commit.
- Use
git diffto view differences between your unstaged changes and the last commit. - You can use the
--stagedoption to view differences between your staged changes and the last commit instead.
$ git diff [--staged]
Example
$ git diff
# Displays the differences between unstaged changes and the last commit
$ git diff --staged
# Displays the differences between staged changes and the last commit
- Distinction
- ⭐unstaged changes: before execute
git add ., like this picture: - ⭐staged changes: after execute
git add ., but beforegit commit -m!
- ⭐unstaged changes: before execute
🔥Here shows the operation:
① before git add
② after git add & before git commit
③ show the diff after git commit
🌊Wish you can benefit from this article. 🍺And welcome to leave your thoughts in the comments section that we can discuss and share ideas with each other.