[Tutor] Questions (and initial responses) on using version control: Why cannot I push my single (master) branch to origin without an error occurring?

boB Stepp robertvstepp at gmail.com
Fri May 1 05:39:42 CEST 2015


I created my remote repository on, say my C-drive, with "git init". I
then copied and pasted a file to that location and put it under
version control with "git add filename.py". Next I went to my E-drive,
which is where I intend to be my working directories. After setting up
a similar directory structure (/Projects/), I typed "git clone
C:/Projects/project_name" and the desired result appeared on E:
E:/Projects/project_name/filename.py. All seemed well with the world!

Now I made some edits to filename.py in my working directory,
added/committed and then attempted to push to the remote repository
and got this:

boB Stepp at DREAMMACHINE1 /e/Projects/project_name (master)
$ git push origin master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 328 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 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'.
To c:/Projects/project_name
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'c:/Projects/project_name'

I did the usual Google search. What I found recommended I cd to the
remote repository, create a new temporary branch, and then checkout
that branch. Then go back to my working directory and then push to the
remote repository. This works. Problem: I don't understand why what I
was originally doing does not allow me to do a push with errors. Would
someone please elucidate?

And since I am obviously not in the know here, my attempted workflow
must be flawed. Would someone point out the "proper" way to initiate a
new project under Git version control?

Thanks!

boB


More information about the Tutor mailing list