1

I want my git repo to be in a separate directory from my working directory, so I made a repo using the following commands:

$ cd mysite.git/
$ git init --bare
Initialized empty Git repository in /home/git/mysite.git
$ git config core.bare false
$ git config core.worktree /home/mysite/public_html
$ git config receive.denycurrentbranch ignore
$ cat > hooks/post-receive
#!/bin/sh
export GIT_DIR=/home/git/mysite.git
export GIT_WORK_TREE=/home/mysite/public_html
git checkout -f
^D
$ chmod +x hooks/post-receive

I seem to be able to push and pull from the repo without error, but the working directory doesn't reflect the pushed changes.

If I do

$ git status

it shows that my changes were commited, but then removed from the working directory.

This configuration was working for my team until recently, and I'm not sure how to track down what might have changed. I've made sure that the file permissions seem to be correct. I'm not sure what else to check.

Can someone please help me figure out why my configuration is causing the working directory to not reflect the commited changes?

phaonica
  • 21
  • 4

2 Answers2

1

It turns out that the permissions in my repo directory were correct, but the permissions in my working directory were not. I had to make sure that the working directory was writable by the user that was doing the push.

phaonica
  • 21
  • 4
0

"Bare" repos do not have worktrees. Maybe this will help?

You need to 'clone' the bare repo. Then you can push from the clone into the bare repo, and pull from the bare repo into the clone.

Community
  • 1
  • 1
cdunn2001
  • 17,657
  • 8
  • 55
  • 45
  • I was attempting to set up automatic deployment of a website via a remote git repo similar to the suggestions on http://caiustheory.com/automatically-deploying-website-from-remote-git-repository/ Is it possible to have your git repo in a different directory than the working directory without initializing the repo as bare? I also need pushing to the repo to automatically commit the changes and update the working directory. – phaonica Feb 24 '15 at 00:22
  • Pushing to a repo does not alter any working directory. But you can do part of what you want. To separate git-dir from workingtree, use `--separate-git-dir `. – cdunn2001 Feb 24 '15 at 01:50