Checking the status, differences, logs & restore
Git - Quick Reference
3 min read
Published Jun 19 2025
Guide Sections
Guide Comments
Checking the current status
You can check the current status at any time:
This tells you:
- Which branch you are on.
- Whether your branch is ahead/behind the remote branch.
- Which files are:
- Untracked - new files not added yet.
- Modified but not staged - ones you have changed but not added yet with
git add
- Staged - added with
git add
, but not committed yet. - Deleted - file deleted, either staged or not.
There is a short format, less verbose version too:
Checking the difference between two states
To see the difference between the current changes and what has already been staged:
Shows the unstaged changes.
To see the staged changes that will go in the next commit:
Shows the differences between the staged version and the last commit, so shows you what will be in the next commit.
Compare two commits:
Use the commit ids for the two commits to check.
Compare branches:
Will compare the my-other-branch and develop branches.
Compare current working directory to a branch:
Will compare current project files to main branch.
All the above will show a file with the following info:
+
- added lines.-
- removed lines.@@
- meta data showing the line numbers.
Commit history
To view the history of commits on your repository:
This tells you:
- When the change was made.
- Who made the change.
- The commit message of what the change contained.
Compact history of just hashes and messages:
Show branches and visual history:
Include the diff
output of each commit:
Undo uncommited changes
You have edited a file but want to discard the changes:
You staged a file and want to unstage it:
You want to undo both staged and working changes:
How this option works:
- If the file already existed - revert to how it was at last commit.
- If the file is new - deletes the file from the working directory and the staged area.
You can add the --dry-run
flag to the git restore
command to see what Git will actually do, without doing it.
Git reset - more destructive undoing
This option is a lot more powerful and can be dangerous and destructive, so use with caution.
Undo a commit but keep your changes staged:
This moves the branch pointer back one commit, but your changes are still staged, ready to commit.
Unstage files - ( like git restore --staged
)
Leaves the working directory untouched, just removes the file from staging.
Fully reset to a previous commit:
Moves the HEAD back one commit, erases all staged and working directory changes.