View Unstaged and Staged Git Modifications
When git status returns “Changes not staged for commit”, you can view the unstaged changes with git diff
A typical example:
❯ git status
On branch main
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: fragment_indexer/hugo.py
no changes added to commit (use "git add" and/or "git commit -a")
❯ git diff
diff --git i/fragment_indexer/hugo.py w/fragment_indexer/hugo.py
index fb40996..957cc04 100644
--- i/fragment_indexer/hugo.py
+++ w/fragment_indexer/hugo.py
@@ -28,8 +28,14 @@ def copy_site(source: Path, target: Path, page_template: str):
config = json.loads(
subprocess.check_output(
[
- "hugo", "config", "--source", str(source),
- "--environment", "minimal", "--format", "json",
+ "hugo",
+ "config",
+ "--source",
+ str(source),
+ "--environment",
+ "minimal",
+ "--format",
+ "json",
],
text=True,
)
You can also view the unstaged changes for just one file with:
git diff -- fragment_indexer/cli.py # just look at unstaged changes for cli.py
Once changes have been staged with git add, view them with:
fragment_indexer main*
❯ git add .
fragment_indexer main*
❯ git diff --staged
diff --git c/fragment_indexer/hugo.py i/fragment_indexer/hugo.py
index fb40996..957cc04 100644
--- c/fragment_indexer/hugo.py
+++ i/fragment_indexer/hugo.py
@@ -28,8 +28,14 @@ def copy_site(source: Path, target: Path, page_template: str):
config = json.loads(
subprocess.check_output(
[
- "hugo", "config", "--source", str(source),
- "--environment", "minimal", "--format", "json",
+ "hugo",
+ "config",
+ "--source",
+ str(source),
+ "--environment",
+ "minimal",
+ "--format",
+ "json",
],
text=True,
)
Tags: