git post-receive hook “empty ident name”

隐身守侯 提交于 2020-01-11 04:22:05

问题


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?


回答1:


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



回答2:


my git version is git 1.7.1 (centos 6.8); Of course , i can not use "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

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

name = server

email = server@minstech.cn

is be added




回答3:


You should also unset:

GIT_COMMITER_NAME
GIT_COMMITER_EMAIL
GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL


来源:https://stackoverflow.com/questions/24850247/git-post-receive-hook-empty-ident-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!