paulb@MacBook-Air-2 hugo-blog2 % git restore --staged .
paulb@MacBook-Air-2 hugo-blog2 % git status
On branch main
Your branch is up to date with ‘origin/main’.
Changes not staged for commit:
(use “git add/rm …” to update what will be committed)
(use “git restore …” to discard changes in working directory)
deleted: content/posts/first-post-121222.md
Untracked files:
(use “git add …” to include in what will be committed)
.gitignore
no changes added to commit (use “git add” and/or “git commit -a”)
paulb@MacBook-Air-2 hugo-blog2 %
paulb@MacBook-Air-2 hugo-blog2 %
paulb@MacBook-Air-2 hugo-blog2 % git add -A
paulb@MacBook-Air-2 hugo-blog2 % git status
On branch main
Your branch is up to date with ‘origin/main’.
Changes to be committed:
(use “git restore --staged …” to unstage)
new file: .gitignore
deleted: content/posts/first-post-121222.md
The root cause: you staged the addition of the new file, but did not stage deletion of the old file. Yes, I know you used mv to rename the file, but Git sees this as an addition and deletion.
I use git add -A almost all of the time to stage additions and deletions.
Always run git status before you commit your change. It shows you what is staged and not staged.