Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting "fatal: not a git repository: '.'" when using post-update hook to execute 'git pull' on another repo

Tags:

git

githooks

I'm new to git so I apologize (and please correct me) if I misuse terminology here, but I'll do my best.

I'm trying to set up a bare git repo (hub) and a development site working copy (prime) on a web server. I've tried to pattern it after this article. I want the development working copy to be updated whenever the hub repo is pushed to. I'm under the impression that the proper hook for this is post-update, which I have created like so:

#!/bin/sh whoami cd /path/to/working-copy/ RET=`git pull` echo $RET 

Update

When I push changes from my local repo to the bare hub I get the following output from the post-update script:

remote: sites remote: fatal: Not a git repository: '.' 

However if I SSH into the server as user 'sites' and execute this script manually it works great Any ideas as to what might be going wrong with this hook or script?

like image 913
Ty W Avatar asked Oct 28 '10 14:10

Ty W


People also ask

How do I fix a fatal Not a git repository?

Check that you correctly created the repo. If the directory doesn't contain a . git repo, use git init to properly initialize the repo or clone an existing repo. Make sure your HEAD file contains the correct information on your current branch.

Why does it say not a git repository?

The “not a git repository” error is common. The cause is running a Git command in the wrong folder or running a Git command before initializing a Git repository.

Does not appear to be a git repository fatal could not read from remote repository?

Note: The “fatal: 'origin' does not appear to be a git repository” error occurs when you try to push code to a remote Git repository without telling Git the exact location of the remote repository. To solve this error, use the git remote add command to add a remote to your project.

Does not appear to be a git repository git pull?

The “… does not a appear to be a git repository” error is triggered when you try to clone, or run other commands, in a directory that is not recognized as a Git repository. The directory or remote file path might not have initialized Git, or the file path you are trying to access as an active repository is incorrect.


1 Answers

Here is the script that ultimately worked. I think the bit I was originally missing that prevented it from working remotely was the unset GIT_DIR

#!/bin/sh cd /path/to/working-copy/ || exit unset GIT_DIR git pull repo branch  exec git-update-server-info 
like image 110
Ty W Avatar answered Sep 29 '22 08:09

Ty W