{"thread":{"id":"55020","subject":"Unable to push to local bare repository","startedAt":"2021-01-20T23:42:51Z","lastAt":"2021-01-21T00:56:52Z","messageCount":2,"participants":["Rich Davis","asymptosis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"414867","messageId":"8f1df022-0e0e-2451-b32d-2d9918604ea1@gmail.com","threadId":"55020","inReplyTo":null,"subject":"Unable to push to local bare repository","fromName":"Rich Davis","fromEmail":"crashvb@gmail.com","sentAt":"2021-01-20T21:58:14Z","receivedAt":"2021-01-20T23:42:51Z","isPatch":false,"sender":{"key":"crashvb@gmail.com","avatar":null},"body":"Hello GIT Community,\n\nI have a question concerning initialization of bare repositories on a\nlocal system; what am I overlooking?\n\nI am attempting to init a bare repository locally, then clone the bare\nrepository to add files, then commit and push the content back:\n\n========== Start Example ==========\n\n$ git init barerepo\nInitialized empty Git repository in /tmp/am_i_crazy/barerepo/.git/\n$ git clone --dissociate --no-hardlinks --no-local barerepo clonerepo\nCloning into 'clonerepo'...\nwarning: You appear to have cloned an empty repository.\nChecking connectivity... done.\n$ cd clonerepo/\n$ echo \"This is a test file created on $(date +%Y-%m-%d_%H:%M:%S)\" >\ntest.txt\n$ git add test.txt\n$ git commit --message \"Initial commit.\"\n[master (root-commit) da5f435] Initial commit.\n 1 file changed, 1 insertion(+)\n create mode 100644 test.txt\n$ git push origin master\nCounting objects: 3, done.\nDelta compression using up to 8 threads.\nCompressing objects: 100% (2/2), done.\nWriting objects: 100% (3/3), 914 bytes | 0 bytes/s, done.\nTotal 3 (delta 0), reused 0 (delta 0)\nremote: error: refusing to update checked out branch: refs/heads/master\nremote: error: By default, updating the current branch in a non-bare\nrepository\nremote: error: is denied, because it will make the index and work tree\ninconsistent\nremote: error: with what you pushed, and will require 'git reset --hard'\nto match\nremote: error: the work tree to HEAD.\nremote: error:\nremote: error: You can set 'receive.denyCurrentBranch' configuration\nvariable to\nremote: error: 'ignore' or 'warn' in the remote repository to allow\npushing into\nremote: error: its current branch; however, this is not recommended\nunless you\nremote: error: arranged to update its work tree to match what you pushed\nin some\nremote: error: other way.\nremote: error:\nremote: error: To squelch this message and still keep the default\nbehaviour, set\nremote: error: 'receive.denyCurrentBranch' configuration variable to\n'refuse'.\nTo /tmp/am_i_crazy/barerepo\n ! [remote rejected] master -> master (branch is currently checked out)\nerror: failed to push some refs to '/tmp/am_i_crazy/barerepo'\n$ git version\ngit version 2.7.4\n========== End Example ==========\n\nFrom what I was able to find in the man page, there is an optimization\nthat takes place locally when the upstream repository is on the same\nsystem / file system; I have attempted to disable that, but I am unsure\nif that is what is causing the problem. I am also curious as to why the\nerror message refers to the upstream repository as \"non-bare\"?\n\n\nThank you for your time,\n\nRich Davis*\n*\n\n\n"},{"id":"414873","messageId":"YAjD+Gtm1QwdwXCq@sleipnir.acausal.realm","threadId":"55020","inReplyTo":"8f1df022-0e0e-2451-b32d-2d9918604ea1@gmail.com","subject":"Re: Unable to push to local bare repository","fromName":"asymptosis","fromEmail":"asymptosis@posteo.net","sentAt":"2021-01-20T23:59:52Z","receivedAt":"2021-01-21T00:56:52Z","isPatch":false,"sender":{"key":"asymptosis@posteo.net","avatar":null},"body":"Hi Rich,\n\n>$ git init barerepo\n>Initialized empty Git repository in /tmp/am_i_crazy/barerepo/.git/\n\nThis looks like your problem: without passing the --bare flag, it's not a bare repo. It even says it's initialized under barerepo/.git instead of barerepo.\n\nCompare with the result of passing --bare:\n\n```\ntestuser /tmp $ git init --bare barerepo\nInitialized empty Git repository in /tmp/barerepo/\n\ntestuser /tmp $ git clone --dissociate --no-hardlinks --no-local barerepo clonerepo\nCloning into 'clonerepo'...\nwarning: You appear to have cloned an empty repository.\n\ntestuser /tmp $ cd clonerepo/\n\ntestuser /tmp/clonerepo $ printf \"This is a test file created on %s\\n\" \"$(date +%Y-%m-%dT%H:%M:%S)\" | tee test.txt\nThis is a test file created on 2021-01-21T10:55:35\n\ntestuser /tmp/clonerepo $ git add test.txt\n\ntestuser /tmp/clonerepo $ git commit -m \"Initial commit\"\n[master (root-commit) b71804b] Initial commit\n  1 file changed, 1 insertion(+)\n  create mode 100644 test.txt\n\ntestuser /tmp/clonerepo $ git push origin master\nEnumerating objects: 3, done.\nCounting objects: 100% (3/3), done.\nWriting objects: 100% (3/3), 253 bytes | 253.00 KiB/s, done.\nTotal 3 (delta 0), reused 0 (delta 0), pack-reused 0\nTo /tmp/barerepo\n  * [new branch]      master -> master\n```\n\nHope this helps.\n"}]}