Arne Lund
Arne Lund

Reputation: 2446

How to configure git to include my name in commits

I have set up my name and email as follows

git config --global user.name myname

However, when I run git log after commit, it shows unknown instead of myname:

Author: unknown <[email protected]>

What should I do to have my name listed by log command?

Edit: the output of config -l is as follows:

core.symlinks=false
core.autocrlf=false
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
sendemail.smtpserver=/bin/msmtp.exe
diff.astextplain.textconv=astextplain
rebase.autosquash=true
gui.recentrepo=C:/Git/MyProject
core.editor='C:\Program Files (x86)\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin
core.autocrlf=false
user.name=myalias
[email protected]
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@git:myproject.git
branch.master.remote=origin
branch.master.merge=refs/heads/master

Edit: started a bounty.

Edit 2: In fact, git commit from command line was including my name, but TortoiseGit failed to do so. So this is a problem with TortoiseGit.

Upvotes: 5

Views: 4130

Answers (5)

Carl
Carl

Reputation: 44448

Here's is how you can change your history. You should probably also check your .mailmap file to see if there are any conflicting settings there.

Upvotes: 3

Scolytus
Scolytus

Reputation: 17137

Create an empty dir with no parent being a git-repository and cd there. Execute the following commands.

git init .
touch foo
git add foo
git commit -m "initial"
git log
git config -l

Please provide the output of git log and git config -l of these two calls.

Upvotes: 5

Kristof Mols
Kristof Mols

Reputation: 3557

the git config --global user.name myname will only take effect with commits done after this change.

Commits pushed before you changed the .gitconfig will keep the old value of user.name

Have you checked with recently done commits?

Upvotes: 5

manojlds
manojlds

Reputation: 301087

Verify that that the username is not overriden ( to unknown ) in GIT_AUTHOR_NAME and GIT_COMMITTER_NAME environment variables and also the local .git/config

If that is not the case, make sure you are committing and not just seeing old log of commits that were done before you set the username. ( one mistake people do is to try commit without staging files etc.)

Upvotes: 3

Greg Hewgill
Greg Hewgill

Reputation: 992857

Do you have your user name set (to "unknown") in your local .git/config? That would override the global setting.

Upvotes: 3

Related Questions