如何配置 git 以在提交中包含我的名字
我已经按如下方式设置了我的姓名和电子邮件
git config --global user.name myname
但是,当我在提交后运行 git log 时,它显示未知而不是我的名字:
Author: unknown <[email protected]>
我应该怎么做才能让 log 命令列出我的名字?
编辑: config -l 的输出如下:
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
编辑:开始赏金。
编辑2:事实上,命令行中的 git commit 包含了我的名字,但 TortoiseGit 未能这样做。所以这是TortoiseGit的问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
创建一个空目录,其中没有父目录作为 git 存储库并 cd 到那里。执行以下命令。
请提供这两个调用的 git log 和 git config -l 的输出。
Create an empty dir with no parent being a git-repository and cd there. Execute the following commands.
Please provide the output of
git log
andgit config -l
of these two calls.git config --global user.name myname
仅在此更改后完成提交后生效。在更改 .gitconfig 之前推送的提交将保留
user.name
的旧值您检查过最近完成的提交吗?
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?
您是否在本地
.git/config
中设置了用户名(设置为“未知”)?这将覆盖全局设置。Do you have your user name set (to "unknown") in your local
.git/config
? That would override the global setting.验证 GIT_AUTHOR_NAME 和 GIT_COMMITTER_NAME 环境变量以及本地
.git/config
中的用户名是否未被覆盖(未知)。如果情况并非如此,请确保您正在提交,而不仅仅是看到旧的设置用户名之前完成的提交日志。 (人们犯的一个错误是尝试在没有暂存文件等的情况下提交。)
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.)
这是 如何改变你的历史记录。
您可能还应该检查您的 .mailmap 文件以查看其中是否存在任何冲突的设置。
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.