How to change the last commit?
git commit --amend --no-edit
To change your last commit, start with adding your changes to the staging area with git add .
.
Running git commit --amend --no-edit
next will add your changes to the last commit without changing the commit message.
git log --oneline
0c5fbac (HEAD -> main) Adding image.png and README.md
9cfff18 Adding file.txt
git status
On branch main
Untracked files:
(use "git add..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)
git add .
git commit --amend --no-edit
[main 16f0fe7] Adding image.png and README.md
Date: Sat May 15 15:24:48 2021 +0200
2 files changed, 1 insertion(+)
create mode 100644 README.md
create mode 100644 image.png
See git commit to learn more about it.