【问题标题】:git post-receive hook "empty ident name"git post-receive hook“空标识名”
【发布时间】:2014-09-11 01:57:48
【问题描述】:

我已经构建了以下接收后挂钩:

#!/bin/sh
cd /var/node/heartbeat/ || exit
unset GIT_DIR
echo $USER
git pull --no-edit

当我推送到存储库时,返回以下错误:

remote:
remote: From server.net:chris/heartbeat
remote:    c0df678..5378ade  master     -> origin/master
remote:
remote: *** Please tell me who you are.
remote:
remote: Run
remote:
remote:   git config --global user.email "you@example.com"
remote:   git config --global user.name "Your Name"
remote:
remote: to set your account's default identity.
remote: Omit --global to set the identity only in this repository.
remote:
remote: fatal: empty ident name (for <git@server.net>) not allowed

当从 git 用户运行 git config -l 时:

user.name=server
user.email=server@server.com
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git@server.net:chris/heartbeat.git
branch.master.remote=origin
branch.master.merge=refs/heads/master

我不明白为什么它仍然认为我的 user.email 和 user.name 是空的,因为 git config -l 告诉我它不是。有谁知道这个问题的解决方案/解决方法?

【问题讨论】:

  • 您是否在服务器端(“远程”端)运行git configecho $USER 的结果在哪里?
  • 是的,我在服务器端运行 git config 并且 echo $USER 的结果是错误的第一个空行。
  • 如果您将 echo 替换为 id -a,您会得到“git”吗?钩子是用户git执行的吗?
  • 返回下面一行,所以是git用户执行的。 remote: uid=1000(git) gid=1000(git) groups=1000(git) 奇怪的是,当我在 su git 之后手动执行钩子时,没有返回错误。
  • 而且,仍然在那个钩子中,git config --local -l 会返回什么?

标签: git gitlab


【解决方案1】:

为确保这项工作,git config --local -l 需要返回用户名和电子邮件。

如果没有,请转到服务器上的那个 repo,然后输入;:

git config user.name server
git config user.email server@server.com

【讨论】:

  • 天哪,终于。在 node.js 中编写这个提交脚本已经两天了。非常感谢!但无法提交,因为作者从未在那里,即使服务器用户确实拥有全局凭据。现在好了。
  • @wytten 您使用的是什么 git 版本?在哪个操作系统上?在 shell 或 CMD 会话中?你输入了什么命令?你把两个'-'放在local前面了吗?
  • @VonC Linux git 1.7.1 'git config --local -l' 谢谢
  • 1.7.1 是古老的,但我相信这个选项应该有效。不过,如果你能升级,那将是最好的。 (unix.stackexchange.com/a/170831/7490)
  • 为什么它不起作用?名称和电子邮件已在全局配置中正确注册
【解决方案2】:

我的 git 版本是 git 1.7.1 (centos 6.8); 当然,我不能使用“git config --local -l”

我的最终解决方案:

转到 git 代码服务器 然后转到您的 home/www/your projecet/.git/ 文件夹以修改配置,如

repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = /home/git/repos/music.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
name = server
email = server@minstech.cn

名称=服务器

email = server@minstech.cn

正在添加

【讨论】:

    【解决方案3】:

    您还应该取消设置:

    GIT_COMMITER_NAME
    GIT_COMMITER_EMAIL
    GIT_AUTHOR_NAME
    GIT_AUTHOR_EMAIL
    

    【讨论】:

    • 我同意。上述环境变量会覆盖git config --local -l 中设置的环境变量。如果它们设置为空字符串,fatal: empty ident name 错误仍然会发生。您可以查看它们是否填充了 env | grep GIT_ 并使用 unset 将其删除。
    猜你喜欢
    • 2015-03-22
    • 2014-06-02
    • 2013-07-17
    • 1970-01-01
    • 2013-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多