Git basics

Set your Git name and email or fix a commit's author

Tell Git who you are, use a different email for one project and fix the last commit's author.

Fill these in once
  1. Set your name for every project
    Terminal
    git config --global user.name "Alex Smith"
  2. Set your email for every project
    Terminal
    git config --global user.email "alex@example.com"

    Use the same email as your GitHub account, so your commits are linked to you.

  3. Use a different email in this project only
    Terminal
    git config user.email "alex@example.com"

    Run it inside the project folder. It wins over the global one.

  4. Fix the author of your last commit
    Terminal
    git commit --amend --reset-author --no-edit

    Only before you push it.

Check it worked

  1. Check the last commit's author
    Terminal
    git log -1 --format="%an <%ae>"
  1. Set your name for every project
    Terminal · Ubuntu / Debian
    git config --global user.name "Alex Smith"
  2. Set your email for every project
    Terminal · Ubuntu / Debian
    git config --global user.email "alex@example.com"

    Use the same email as your GitHub account, so your commits are linked to you.

  3. Use a different email in this project only
    Terminal · Ubuntu / Debian
    git config user.email "alex@example.com"

    Run it inside the project folder. It wins over the global one.

  4. Fix the author of your last commit
    Terminal · Ubuntu / Debian
    git commit --amend --reset-author --no-edit

    Only before you push it.

Check it worked

  1. Check the last commit's author
    Terminal · Ubuntu / Debian
    git log -1 --format="%an <%ae>"
  1. Set your name for every project
    PowerShell
    git config --global user.name "Alex Smith"
  2. Set your email for every project
    PowerShell
    git config --global user.email "alex@example.com"

    Use the same email as your GitHub account, so your commits are linked to you.

  3. Use a different email in this project only
    PowerShell
    git config user.email "alex@example.com"

    Run it inside the project folder. It wins over the global one.

  4. Fix the author of your last commit
    PowerShell
    git commit --amend --reset-author --no-edit

    Only before you push it.

Check it worked

  1. Check the last commit's author
    PowerShell
    git log -1 --format="%an <%ae>"