1

I want to create a git repo on my server to update my website after pushing. The first step of all tutorials(such as this: http://developertheory.com/how-to-auto-deploy-apps-after-git-push/) I found, is this command:

git init --bare

In the next steps I should enter the following commands:

git config core.worktree /path/to/git/deploy
git config core.bare false
git config receive.denycurrentbranch ignore

the second command (git config core.bare false) set the repo to non-bare. Why do we init the repo as bare and then set it to non-bare?!

user16948
  • 4,801
  • 10
  • 30
  • 41
  • Can you describe exactly what you are trying to do? What do you mean by "update my website after pushing"? – sinelaw Feb 14 '13 at 14:36
  • I mean I want to checkout automatically after I enter `git push` in my local system. Please see the url I just added to post – user16948 Feb 14 '13 at 14:42

1 Answers1

1

I suspect this tutorial uses git init --bare as a "clean" way to create an empty repo which cannot be mixed with the actual files:

Such a repo will contain directly the .git usual content, even after being re-configure as non-bare.
You need a non-bare repo in order for the git checkout (in the hook) to work, since you can only checkout a branch in a non-bare repo (a bare one, by definition, has no working tree).

I wouldn't recommend that method for deployment though, and I prefer:

  • keeping that repo bare in order to push to it
  • setting up a second repo, non-bare
  • adding a post-receive hook on the first (bare) repo in order for the second one to pull from what the first one just received.

See for instance:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250