Undo Git mistakes

Change your last commit message

Fix a typo or a vague message in the commit you just made.

Fill these in once
  1. Change the message
    Terminal
    git commit --amend -m "Fix the typo on the home page"
  2. Already pushed? Update GitHub too
    Terminal
    git push --force-with-lease

    Only on your own branches: it rewrites history others may have pulled.

Check it worked

  1. See the new message
    Terminal
    git log --oneline -3
  1. Change the message
    Terminal · Ubuntu / Debian
    git commit --amend -m "Fix the typo on the home page"
  2. Already pushed? Update GitHub too
    Terminal · Ubuntu / Debian
    git push --force-with-lease

    Only on your own branches: it rewrites history others may have pulled.

Check it worked

  1. See the new message
    Terminal · Ubuntu / Debian
    git log --oneline -3
  1. Change the message
    PowerShell
    git commit --amend -m "Fix the typo on the home page"
  2. Already pushed? Update GitHub too
    PowerShell
    git push --force-with-lease

    Only on your own branches: it rewrites history others may have pulled.

Check it worked

  1. See the new message
    PowerShell
    git log --oneline -3