Interview Prep/Git & GitHub/Commits, branches and tags

How do you change the last commit message or add a forgotten file?

BeginnerConceptCommits, branches and tags
Answer

Use git commit --amend. It replaces the last commit with a new one, so the ID changes. Only do this if the commit has not been shared, or be ready to force-push with lease.

git add forgotten.txt
git commit --amend --no-edit
git commit --amend -m "better message"
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags