Unable to push to local bare repository
- From
- Rich Davis <crashvb@gmail.com>
- Date
- Jan 20, 2021, 21:58 UTC
- Message-ID
- <8f1df022-0e0e-2451-b32d-2d9918604ea1@gmail.com>
Hello GIT Community,
I have a question concerning initialization of bare repositories on a local system; what am I overlooking?
I am attempting to init a bare repository locally, then clone the bare repository to add files, then commit and push the content back:
========== Start Example ==========
$ git init barerepo Initialized empty Git repository in /tmp/am_i_crazy/barerepo/.git/ $ git clone --dissociate --no-hardlinks --no-local barerepo clonerepo Cloning into 'clonerepo'... warning: You appear to have cloned an empty repository. Checking connectivity... done. $ cd clonerepo/ $ echo "This is a test file created on $(date +%Y-%m-%d_%H:%M:%S)" > test.txt $ git add test.txt $ git commit --message "Initial commit." [master (root-commit) da5f435] Initial commit. 1 file changed, 1 insertion(+) create mode 100644 test.txt $ git push origin master Counting objects: 3, done. Delta compression using up to 8 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (3/3), 914 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) 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: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. remote: error: remote: error: You can set 'receive.denyCurrentBranch' configuration variable to remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into remote: error: its current branch; however, this is not recommended unless you remote: error: arranged to update its work tree to match what you pushed in some remote: error: other way. remote: error: remote: error: To squelch this message and still keep the default behaviour, set remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'. To /tmp/am_i_crazy/barerepo ! [remote rejected] master -> master (branch is currently checked out) error: failed to push some refs to '/tmp/am_i_crazy/barerepo' $ git version git version 2.7.4 ========== End Example ==========
From what I was able to find in the man page, there is an optimization that takes place locally when the upstream repository is on the same system / file system; I have attempted to disable that, but I am unsure if that is what is causing the problem. I am also curious as to why the error message refers to the upstream repository as "non-bare"?
Thank you for your time,
Rich Davis* *