How to fix my renaming of a post filename

Done from the root dir:

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

paulb@MacBook-Air-2 hugo-blog2 %

Perfect!

Now…

git commit -m "Finally delete the file and add a gitignore"
git push

So use “git push” instead of “git push origin main” which I usually use?

Sorry I didn’t answer yesterday, gohugo.io limits the number of community posts I can make per day initially.

git push origin main is a fully-qualified command.

In your case, I suspect that git push will do exactly the same thing.

See https://git-scm.com/docs/git-push for more info.

You really, really need to spend some time learning Git. There are books, tutorials, and the official documentation.

Looks like your site is working as expected.

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.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.