Keep Getting "fatal: This operation must be run in a work tree"

时间:2016-04-04 17:36:06

标签: git

I'm managing a site using the setup in this article: http://toroid.org/git-website-howto

It has been working great for several years but I recently moved the site to AWS and had to reconfigure the remote repo. Here is my setup:

  • Local repo setup using git init, then added all the files
  • Remote repo setup using git --init bare
  • Created post-receive file in the remote hooks folder, chmod +x to make it executable

The hook contains the following:

#!/bin/sh
GIT_WORK_TREE=/path/to/destination/folder/for/checkout git checkout -f

Whenever I try running the hook (from the root of the bare remote repo):

./hooks/post-receive

I get

fatal: This operation must be run in a work tree

I have tried making the remote repo NOT bare, but that did not work. I am on Ubuntu 14.04 using git 2.5.8

Any help or pointers appreciated!

1 个答案:

答案 0 :(得分:0)

我通过将最终目的地视为存储库来解决这个问题(因为它实际上是lol)所以现在post-receive挂钩看起来像这样:

#!/bin/sh
cd /final/destination/path
git checkout origin -f