5

When I type git log the resulting list of commits show my password in brackets <> after my username, like this:

commit 5ff14f929e2244f388a41b6f711e7b9b58c57cb2
Author: herman <MyPassw0rd>
Date:   Wed Aug 29 10:00:39 2018 +0200

initial commit 

Why does it do this, and how do I fix it?

Herman
  • 750
  • 1
  • 10
  • 23

1 Answers1

14

That's not supposed to be your password, it should be your email. While I have no idea how you entered your password into the email setting, you can set your email in the current project using

git config user.email "email@example.com"

or globally using

git config --global user.email "email@example.com"

Also, you should likely change your password.

Amadan
  • 191,408
  • 23
  • 240
  • 301
  • Thanks! I've changed this setting and now my e-mail is shown for new commits. However my old commits still contain the old password. I've tried to change it by hand in the /git folder. I could find the log in *.git/logs/HEAD* and *.git/logs/refs/heads/master* and changed it there, but when I type `git log` it still shows them. What can I do? – Herman Aug 29 '18 at 12:20
  • 1
    [Git, rewrite previous commit usernames and emails](https://stackoverflow.com/a/11768843/240443). However, if you shared your repository with anyone, this will mess with the history and you probably don't want to do that (or you should force-push, then have everyone clone anew). And change your password. – Amadan Aug 29 '18 at 12:23
  • Thanks! But I get the message `git: 'change-commits' is not a git command.` I can find the command `git update-ref`. (git version 2.15.2 (Apple Git-101.1)) – Herman Aug 29 '18 at 12:34
  • 1
    Read the answer till the end :) It explains that it's a git alias, and gives its definition. (You can even see how it's defined in a .gitconfig file) – Amadan Aug 29 '18 at 12:34
  • 1
    Thanks! I managed to do it with `git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='newemail'; GIT_COMMITTER_NAME='committed-name'; GIT_COMMITTER_EMAIL='committed-email';" HEAD` – Herman Aug 29 '18 at 12:39
  • As long as you're aware that there's no conditional logic there - it will change _all_ commits. I hope you don't have collaborators. :) – Amadan Aug 29 '18 at 12:48