git post-receive hook “empty ident name”

2019-02-16 07:11发布

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 "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

When running git config -l from the git user:

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

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?

标签: git gitlab
2条回答
倾城 Initia
2楼-- · 2019-02-16 07:21

You should also unset:

GIT_COMMITER_NAME
GIT_COMMITER_EMAIL
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
查看更多
时光不老,我们不散
3楼-- · 2019-02-16 07:39

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

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

git config user.name server
git config user.email server@server.com
查看更多
登录 后发表回答