git commit -a -m "wrong commit, needs changes" # commit only staged changes, miss untracked changes
git add forgotten_file edited_file ... # stage the changes to fix previous commit
git commit --amend --no-edit # commit staged changes, without editing commit message
git commit --amend -m "revised commit message" # edit commit message, and commits staged changes if any
git commit --amend --reset-author # revise commit author info (for when committed as wrong user)
git commit --no-verify # bypasses commit-msg hooks too
git config user.name="John Doe" # add --global flag for global configuration
git config user.email="jd@example.com" # add --global flag for global configuration
git config author.name="John Doe" # for use when author is a different user
git config author.email="mail@example.com" # for use when author is a different user
git config committer.name="John Doe" # for use when committer is a different user
git config committer.email="mail@example.com # for use when committer is a different user
GIT_AUTHOR_NAME
, GIT_AUTHOR_EMAIL
, GIT_COMMITTER_NAME
, GIT_COMMITTER_EMAIL
and EMAIL
environment variables override above settings.
revert
creates new commit(s) to undo commit(s).reset
discards a commit.
Following command discards the last commit completely.
git reset --hard HEAD~1