如何配置 git 以在提交中包含我的名字

发布于 2024-12-11 07:14:23 字数 1480 浏览 0 评论 0原文

我已经按如下方式设置了我的姓名和电子邮件

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

莳間冲淡了誓言ζ 2024-12-18 07:14:23

创建一个空目录,其中没有父目录作为 git 存储库并 cd 到那里。执行以下命令。

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

请提供这两个调用的 git log 和 git config -l 的输出。

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.

摘星┃星的人 2024-12-18 07:14:23

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?

紧拥背影 2024-12-18 07:14:23

您是否在本地 .git/config 中设置了用户名(设置为“未知”)?这将覆盖全局设置。

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

↘人皮目录ツ 2024-12-18 07:14:23

验证 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.)

浪漫人生路 2024-12-18 07:14:23

这是 如何改变你的历史记录
您可能还应该检查您的 .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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文