git post-receive hook"空的身份名称"

时间:2014-07-20 11:57:08

标签: git gitlab

我构建了以下post-receive hook:

#!/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告诉我它不是。有没有人知道这个问题的解决方案/解决方法?

3 个答案:

答案 0 :(得分:27)

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

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

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

答案 1 :(得分:0)

我的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

名称=服务器

电子邮件= server@minstech.cn

被添加

答案 2 :(得分:-2)

You should also unset:

GIT_COMMITER_NAME
GIT_COMMITER_EMAIL
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL