git post-receive 钩子“空身份名称”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24850247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:19:11  来源:igfitidea点击:

git post-receive hook "empty ident name"

gitgitlab

提问by user2817219

I have built the following post-receive hook:

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

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

When I'm pushing to the repository the following error is returned:

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

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 "[email protected]"
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 <[email protected]>) not allowed

When running git config -l from the git user:

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

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

I don't understand why it's still thinking that my user.email and user.name are empty as git config -l tells me it's not. Does anyone know a solution/workaround for this problem?

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

回答by VonC

To make sure this work, a git config --local -lneeds to return the user name and email.

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

If it doesn't, go to that repo on the server, and type;:

如果没有,请转到服务器上的该存储库,然后键入::

git config user.name server
git config user.email [email protected]

回答by dragon.DK

my git version is git 1.7.1 (centos 6.8); Of course , i can not use "git config --local -l"

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

My final solution:

我的最终解决方案:

goto the git code server then goto your home/www/your projecet/.git/ folder to modify the config like

转到 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 = [email protected]

name = server

名称 = 服务器

email = [email protected]

电子邮件 = [email protected]

is be added

被添加

回答by Sebastian Pütz

You should also unset:

您还应该取消设置:

GIT_COMMITER_NAME
GIT_COMMITER_EMAIL
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL