Shell/Bash: git commit amend without changing message Example


Shell/Bash Example: This is the "git commit amend without changing message" Example. compiled from many sources on the internet by

change git commit message

git commit --amend -m "New commit message"

git amend commit message after push

$ git commit --amend -m "New and correct message"

git commit amend without changing message

git commit --amend --no-edit

git reset amend

# Move the current head so that it's pointing at the old commit
# Leave the index intact for redoing the commit.
# [email protected]{1} gives you "the commit that HEAD pointed at before 
# it was moved to where it currently points at". Note that this is
# different from HEAD~1, which gives you "the commit that is the
# parent node of the commit that HEAD is currently pointing to."
git reset --soft [email protected]{1}

# commit the current tree using the commit details of the previous
# HEAD commit. (Note that [email protected]{1} is pointing somewhere different from the
# previous command. It's now pointing at the erroneously amended commit.)
git commit -C [email protected]{1}

add change to last commit

$ (some_branch) git commit --amend

* Summary: This "git commit amend without changing message" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!