Git Snippets

Some useful git snippets.

Table of Contents

1. Display What Has Been Modified

Use git diff or git show to show the difference. git diff HEAD shows the changes between current workspace and the latest commit.

git diff HEAD "<file_path>"
# or
git diff HEAD -- "<file_path>"

git show "<commit>" displays what a commit has modified (compared to its previous commit)

git show @ # @ is an abbreviation for the latest commit

2. Git Stash

git stash allows us to switch to other branches (e.g., to fix a bug) without discarding changes in the current workspace, or bringing the changes to the target workspace.

Date: 2026-10-27 Tue

Author: ArcaLunar