Reputation: 24558
As I have created a shared repo folder, with path: //web1/www In another PC, I created a folder, and opened bash, I did:
$ git clone //web1/www
Then in the new created repo folder:
$ git status
# On branch master
nothing to commit, working directory clean
I added a file and then:
$ git add .
$ git commit -m 'new file added'
$ git push origin master
But, here is what I get the error below, what shall I do now?
s.ali@WEB2 /d/ketab projects/www (master)
$ git push origin master
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 257 bytes, done.
Total 2 (delta 1), 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 inconsist
ent
remote: error: with what you pushed, and will require 'git reset --hard' to matc
h
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'.
P.S: I am on Windows 7 local network, using domain not a workgroup
Upvotes: 2
Views: 3582
Reputation: 4319
This is because your origin is a full repository.
If you want to push to a repo it needs to be a bare one (no working tree)
when creating the repo use the --bare flag
git init --bare
the push command only updates the internal git files, not the working directory. so in essence, if you push to a full repo the HEAD (the checked out files in the working directory) will actually be behind the bleeding edge commit you just pushed. So the git developers decided to not allow this.
Upvotes: 2