【问题标题】:Commit -m not working after staging changes提交 -m 在暂存更改后不起作用
【发布时间】:2020-04-23 00:00:50
【问题描述】:

我以前使用过很多次 git,但自从我安装了新的 Linux 后,我一直无法提交我的更改。我不断收到此错误:

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: empty ident name (for <my@mail.com>) not allowed

当然,我使用自己的凭据运行提供的步骤,每次尝试提交更改时都会收到相同的错误。

    git config -l --show-origin
    file:/home/george/.gitconfig    user.email=my@mail.com
    file:/home/george/.gitconfig    user.name=George Lastname
    file:.git/config        core.repositoryformatversion=0
    file:.git/config        core.filemode=true
    file:.git/config        core.bare=false
    file:.git/config        core.logallrefupdates=true
    file:.git/config        remote.origin.url=https://github.com/mygithub/repo
    file:.git/config        remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    file:.git/config        branch.master.remote=origin
    file:.git/config        branch.master.merge=refs/heads/master

【问题讨论】:

  • 您是否有可能安装了两个不同版本的 Git,其中一个使用 /home/george/.gitconfig 进行 --global 设置,其中一个使用其他目录进行 --global 设置?

标签: linux git github git-commit git-config


【解决方案1】:

Git 需要知道您的个人姓名 (user.name) 和电子邮件地址 (user.email) 才能将这些值嵌入到您的提交和标签中。在您的情况下,您有一个有效的电子邮件地址,但您没有指定个人姓名。

您应该按照上面的建议运行设置user.namegit config 命令。请注意,这不是您在任何系统上的用户名,而是您的个人姓名(例如,“Pat Doe”或“Sam Smith”)。凭据与此无关。

【讨论】:

  • 感谢您的帮助,但是,我仍然不断收到相同的错误。有没有办法重置全局用户名和电子邮件?
  • 请编辑您的问题以将git config -l ---show-origin 的输出包含为代码块。
  • 当我运行 git config 命令时,它会正确显示我的全局用户和电子邮件并更新。
猜你喜欢
  • 1970-01-01
  • 2023-01-08
  • 2020-12-15
  • 2012-09-10
  • 1970-01-01
  • 2018-11-22
  • 1970-01-01
  • 1970-01-01
  • 2015-11-19
相关资源
最近更新 更多