git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Unable to push to local bare repository
@ 2021-01-20 21:58 Rich Davis
  2021-01-20 23:59 ` asymptosis
  0 siblings, 1 reply; 2+ messages in thread
From: Rich Davis @ 2021-01-20 21:58 UTC (permalink / raw)
  To: git

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*
*



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Unable to push to local bare repository
  2021-01-20 21:58 Unable to push to local bare repository Rich Davis
@ 2021-01-20 23:59 ` asymptosis
  0 siblings, 0 replies; 2+ messages in thread
From: asymptosis @ 2021-01-20 23:59 UTC (permalink / raw)
  To: Rich Davis; +Cc: git

Hi Rich,

>$ git init barerepo
>Initialized empty Git repository in /tmp/am_i_crazy/barerepo/.git/

This 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.

Compare with the result of passing --bare:

```
testuser /tmp $ git init --bare barerepo
Initialized empty Git repository in /tmp/barerepo/

testuser /tmp $ git clone --dissociate --no-hardlinks --no-local barerepo clonerepo
Cloning into 'clonerepo'...
warning: You appear to have cloned an empty repository.

testuser /tmp $ cd clonerepo/

testuser /tmp/clonerepo $ printf "This is a test file created on %s\n" "$(date +%Y-%m-%dT%H:%M:%S)" | tee test.txt
This is a test file created on 2021-01-21T10:55:35

testuser /tmp/clonerepo $ git add test.txt

testuser /tmp/clonerepo $ git commit -m "Initial commit"
[master (root-commit) b71804b] Initial commit
  1 file changed, 1 insertion(+)
  create mode 100644 test.txt

testuser /tmp/clonerepo $ git push origin master
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 253 bytes | 253.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To /tmp/barerepo
  * [new branch]      master -> master
```

Hope this helps.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-21  0:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20 21:58 Unable to push to local bare repository Rich Davis
2021-01-20 23:59 ` asymptosis

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).