Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
537 views
in Technique[技术] by (71.8m points)

git post-receive not working correctly

I have the following problem. I have updated the 'post-receive' to cd into a certain directory and then pull the repo in to deploy it like so:

#!/bin/bash
cd /var/www/site
git pull origin master

However whenever I do 'git push origin master' on my local machine I get the following:

Counting objects: 5, done.
Delta compression using up to 2  threads.
(etc..)
remote: fatal: Not a git repository: '.'

Yet when I manually cd to /var/www/site and do git pull origin master it works brilliantly.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use unset GIT_DIR as following

#!/bin/bash
cd /var/www/site || exit
unset GIT_DIR
git pull origin master
exec git-update-server-info

You can see more information about GIT_DIR here. Git Loves the Environment


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...