Discussion:
[Tutor] Questions (and initial responses) on using version
boB Stepp
2015-05-01 03:39:42 UTC
Permalink
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 ***@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
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Alex Kleider
2015-05-01 04:21:30 UTC
Permalink
Post by boB Stepp
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
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
I would suggest the following work flow to set up two parallel
repositories:

cd <first repo directory>
git init
<do what ever>
git add <files on which you did what ever>
git commit

cd <directory where you want the same repository>
git clone <first repo directory>
# the above command brings in a copy of all that was committed in the
first repo.

Once this is done, I believe your subsequent commits can be pushed
without the errors.



_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
boB Stepp
2015-05-02 03:45:24 UTC
Permalink
Post by Alex Kleider
Post by boB Stepp
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
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
cd <first repo directory>
git init
<do what ever>
git add <files on which you did what ever>
git commit
cd <directory where you want the same repository>
git clone <first repo directory>
# the above command brings in a copy of all that was committed in the first
repo.
Once this is done, I believe your subsequent commits can be pushed without
the errors.
https://mail.python.org/mailman/listinfo/tutor
But this is what I did, and I got the pasted error. Is there some
difference between what you are saying and what I posted that I am not
picking up on?
--
boB
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
boB Stepp
2015-05-02 04:19:43 UTC
Permalink
----------------------------
Post by boB Stepp
I created my remote repository on, say my C-drive, with "git init".
Not with 'git init --bare'?
Should I have used the option --bare? I was following along with the
book, "Pro Git", which is available free on-line via the Git website.
I usually prefer initializing a remote with a readme, so I can simply clone it and then populate it with files. No 'git init' and 'git remote add' needed.
I'm not certain I am following you here. When you say you are
"initializing a remote with a readme", have you first run "git init"
or "git init --bare" in that directory? And I presume the readme is
the typical readme file that most projects have? And then you go to
your working directory and run your git clone command? And then as you
generate files in your working directory, you push them to the remote?
This book is good: https://pragprog.com/book/pg_git/pragmatic-guide-to-git
Thanks for the link. Just now ordered it.
--
boB
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
boB Stepp
2015-05-03 02:58:29 UTC
Permalink
http://stackoverflow.com/questions/7861184/what-is-the-difference-between-git-init-and-git-init-bare
Isn't the error you mentioned before the same?
After reading everything on the page you link to, plus the little bit
on Git in "Introducing Python" by Bill Lubanovic, I think I understand
what is going on a bit better. My current understanding is this: The
workflow that I originally did resulted in TWO working directories
being created with the same branch name, master; one where I meant the
remote repository to be and one where I really meant for my work to be
done. The error message reflects that Git will not allow both working
directories to be working on the same branch at the same time, as Git
has to allow for others wanting to access the repository and the
branch master. Thus when I created a new branch on the repository and
checked it out, there was now only one working directory actively
developing the master branch, *not* at the repository's location. The
repository's working directory was then set to have the new branch
developed. Of course this was a throw away branch, to allow me to push
to the repository from my *real* working directory. I don't know if I
am saying this particularly well as I am still wrapping my mind around
how Git structures things.

I could have done one of two things:

1) Created a repository using "git init", and have my working
directory there. In this instance, there would be no need for push or
pull commands. Or,

2) Created a bare repository. This would result in there being NO
working directory in that location. Go to my desired working directory
location and type "git init". Create files, edit them, etc.,
adding/committing them there. When I am ready to push, I can push to
the remote "bare" repository. No error messages result as no working
directories exist on its location.

My intent in having my work stored on two different hard drives, was
to cover myself if one hard drive failed. So I tested arrangement (2)
tonight. After generating some test files and pushing them to the
remote directory, I grew concerned when I did not see any of the files
I pushed there! But I followed through and deleted everything off of
my working directory hard drive to simulate it crashing. While still
there I typed "git clone remote_repo_location" and voila! My files
returned!! I don't totally understand everything yet, but it makes a
lot more sense now.

boB
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Loading...