0

I have a repository hosted on a server and I want developers to contribute to it. So I tried to clone the repo to my local machine, edit a file and push it back (all on the master branch) as described here in section "Private Small Team".

every time I try to push using git push origin master I get an error that says:

[remote rejected] master -> master (branch is currently checked out)

I have read the error description git is issuing but unsure on how to proceed.

To squelch this message and still keep the default behaviour, set 'receive.denyCurrentBranch' configuration variable to 'refuse'

Is this safe? Is this the correct way? Why does it happens and is not in the linked example? I am concerned about this sentence mostly:

By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent

matt
  • 515,959
  • 87
  • 875
  • 1,141
Lelio Faieta
  • 6,457
  • 7
  • 40
  • 74
  • 2
    You probably want to setup your hosted repo on the server as a bare repo instead of a regular repo. – TTT Sep 22 '21 at 15:41
  • 1
    Since you're reading the Git book, [section 4.2](https://git-scm.com/book/it/v2/Git-on-the-Server-Getting-Git-on-a-Server) talks about setting up the server. – TTT Sep 22 '21 at 15:54
  • @TTT thanks, that was what I was looking for – Lelio Faieta Sep 22 '21 at 16:49
  • https://stackoverflow.com/a/14879452/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+branch+is+currently+checked+out – phd Sep 22 '21 at 18:16

1 Answers1

3

I am concerned about this sentence mostly:

By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent

You should be concerned about it. You'll be much happier if the repo to which others can contribute directly is a bare repo.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • am i then able to push from a bare repo to another? isn't a bare repo a "terminal" report where changes are not pushed anywhere else? – Lelio Faieta Sep 22 '21 at 16:07