在提交linux时git使用root代替我的用户名

Rah*_*nar 2 linux git github

我有一台运行Git的Linux机器。我检查了一个仓库,并从linux commnad行进行提交。当我执行推和拉操作时,它会问我我的用户名和密码,然后显示成功。

但是,在日志中,它显示由root提交。我检查了git config,但找不到任何东西。

这是我的配置文件的值:

core.repositoryformatversion=0 
core.filemode=false
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/my-username/RepositoryName.git
branch.stage.remote=origin
branch.stage.merge=refs/heads/stage
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 5

您需要设置您的user.name和your.email

git config --global user.name xxx
git config --global user.email xxx@mail.com
Run Code Online (Sandbox Code Playgroud)

如果仅执行了一次提交,则可以对其进行修改:

git commit --amend --author "New Author Name <email@address.com>"
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参见“ 在Git中更改提交的作者 ”。

如果执行了几次提交,则需要重写那些提交(请参阅“ 在一个特定的提交处更改提交作者 ”)