Skip to content

Instantly share code, notes, and snippets.

@anuragregmi
Last active December 3, 2019 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anuragregmi/571c5fda4d25db4845313a45c1d88f57 to your computer and use it in GitHub Desktop.
Save anuragregmi/571c5fda4d25db4845313a45c1d88f57 to your computer and use it in GitHub Desktop.
Setting Up bare repo on server

Set up Bare git repo on server

Create a folder to keep our code(work tree of git)

mkdir /home/user/app/

Create a folder for git (eg. repo.git) and cd

mkdir repo.git
cd repo.git

Initialize bare repo and configure worktree

git init --bare
git --bare update-server-info
git config core.bare false
git config receive.denycurrentbranch ignore
git config core.worktree /home/user/app/

Write hooks to update worktree on receiving commits

cat > hooks/post-receive <<EOF
#!/bin/sh
git checkout -f
EOF

chmod +x hooks/post-receive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment