Skip to content

Instantly share code, notes, and snippets.

@Matrixbirds
Last active October 17, 2019 04:07
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 Matrixbirds/0bfb3dd600cf6712404248d90f60175d to your computer and use it in GitHub Desktop.
Save Matrixbirds/0bfb3dd600cf6712404248d90f60175d to your computer and use it in GitHub Desktop.
git bare repo simple solution
.git/hooks/post-receive
#!/bin/bash
WORK_TREE="../"
git --work-tree="${WORK_TREE}" reset --hard
git bare repos doesn't contain the work tree.
you can git init in the same directory
Enumerating objects: 345, done.
Counting objects: 100% (345/345), done.
Delta compression using up to 4 threads
Compressing objects: 100% (331/331), done.
Writing objects: 100% (345/345), 15.88 MiB | 934.00 KiB/s, done.
Total 345 (delta 185), reused 0 (delta 0)
remote: Resolving deltas: 100% (185/185), done.
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To x.x.x.x:/home/pi/gitd/picar.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'user@x.x.x.x:/home/pi/gitd/picar.git'
resolve above error, you need add git config receive.denyCurrentBranch ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment