* Re: Newbie using git -- need a little help
@ 2007-06-17 20:06 Robert Smith
2007-06-17 20:30 ` Thomas Glanzmann
0 siblings, 1 reply; 5+ messages in thread
From: Robert Smith @ 2007-06-17 20:06 UTC (permalink / raw)
To: Thomas Glanzmann; +Cc: git
Thanks for the quick reply. I have a few questions regarding the infrastructure you described...
> When you push to your server, the repository is updated (that is the
> thing that is in .git) but your working tree isn't.
> So when you push to a repository that also has a working tree attached
> to it, you have to do a "git checkout" on the working tree. Or pull from
> the repository and not push to it.
Ahhh, that makes sense... :)
> Than I publish my project to the server without giving the repository at
> the server a working directory attached to it. A working directory is
> where you can edit files and commit changes locally, just in case I
> didn't introduce the term yet.
> # This creates the repository _without_ the working tree on the server.
> ssh 131.188.30.102 git --git-dir=/home/cip/adm/sithglan/work/repositories/private/astro.git init-db
The /home/cip/adm/sithglan/work/repositories/private/astro.git is simply a .git directory located on the "server", and it doesn't actually contain any working code (yet), right?
> # This adds the remote origin to the config so that I don't have to
> # type in the long repository path each time I am going to push or pull
> # something.
> git remote add origin 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git
So what this command is doing is telling git where the "origin" is -- on the remote server, correct? Also, is the default protocol (since all you typed was 131.188.30.102:/.../astro.git) is SSH correct?
> # Now I publish my stuff to the central repository. You need at least
> # one commit in order to be able to do that.
> git push origin master:master
>
> # I add a few lines to my config so that when I type in "git pull" it
> #fetches the stuff and merges it with my local repositories master branch.
>
> "vim .git/config" and add the following lines:
>
> [branch "master"]
> remote = origin
> merge = refs/heads/master
> EOF
I'm a little lost on what 'origin' refers to precisely. Is origin considered the "root" of all the changes (the workspace as it was originally before any patches)? Or is it a location for the working files? You give a definition below in your e-mail but I'm still not completely sure what it is referring to.
> # Now I can fetch back to see if everything works
> git pull
Makes sense...let me give this a try. :)
> Now I am fine the infrastructure is all set up. The next time I am going
> to access the project from a different machine I simply do:
>
> git pull 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git
>
> And that's it. The origin and where it is going to merge stuff is set
> automatically up by git. Note: I use ssh (attached to a ssh-agent so that I
> don't have to passwords all the time I am doing a push or pull). I hope that
> helps you and didn't miss your original question. I just fly over your e-Mail
> and picked a few keywords to comment on.
Awesome...thanks, Thomas. I'll tinker around with this a little more and see if I can get this working as wanted.
Thanks again.
- robert -
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Newbie using git -- need a little help
2007-06-17 20:06 Newbie using git -- need a little help Robert Smith
@ 2007-06-17 20:30 ` Thomas Glanzmann
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Glanzmann @ 2007-06-17 20:30 UTC (permalink / raw)
To: Robert Smith; +Cc: GIT
Hello Robert,
> The /home/cip/adm/sithglan/work/repositories/private/astro.git is
> simply a .git directory located on the "server", and it doesn't
> actually contain any working code (yet), right?
Right.
(faui02) [~/work/repositories/private/astro.git] ls
HEAD branches/ config description hooks/ info/ objects/ refs/ remotes/
> So what this command is doing is telling git where the "origin" is --
> on the remote server, correct? Also, is the default protocol (since
> all you typed was 131.188.30.102:/.../astro.git) is SSH correct?
The default protocol is git over ssh. And it adds a shorthand called
origin that points to the repository at the server you can now say:
git push origin
git pull origin
Since origin is the default, you can also say:
git push
git pull
Note when you do a "git clone ip:/path/to/dir.git", git will
automatically set up the reference to origin. You don't have to do it
yourself. In my initial example you had to do it yourself, because at
the time you started with the new project there was no origin because
you just started it.
> I'm a little lost on what 'origin' refers to precisely. Is origin
> considered the "root" of all the changes (the workspace as it was
> originally before any patches)? Or is it a location for the working
> files? You give a definition below in your e-mail but I'm still not
> completely sure what it is referring to.
"origin" is a shorthand for the remote repository. If you say git pull
git fetches the objects that are reference in the remote repository by
the head "master" (by default) and puts that in a local file called
.git/refs/remotes/origin/master:
(faui02) [~/work/blastwave] ls -al .git/refs/remotes/origin/master
-rw-r--r-- 1 sithglan icipguru 41 Jun 14 18:35 .git/refs/remotes/origin/master
(faui02) [~/work/blastwave] cat !$
cat .git/refs/remotes/origin/master
50da5cf500b8b57e32720ffe80fbabaadd7c8c9f
After that it tries to merge that remote head into your local branches
head. Most of the time that is .git/refs/heads/master
If you type in only "git fetch" it gets the objects but doesn't do any
merging.
So to answer your question. Origin is a copy of the repository you
pull/push by default. The objects of these tree are in your object store
but the actualy HEAD commit object is in the file I "cat" earlier in
this e-Mail.
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Newbie using git -- need a little help
@ 2007-06-17 18:55 Robert Smith
2007-06-17 19:17 ` Thomas Glanzmann
2007-06-19 4:10 ` J. Bruce Fields
0 siblings, 2 replies; 5+ messages in thread
From: Robert Smith @ 2007-06-17 18:55 UTC (permalink / raw)
To: git
Hi,
I apologize right off the bat for the stupid newbie questions. I've read over the documentation (the full manual) numerous times and must admit it's slightly overwhelming. What I'm trying to do is pretty basic, though, so hopefully someone can help me out. Please forgive me for the long post (I'm going to try to describe exactly what I'm doing so that someone can point me to what I'm doing wrong).
I have both a desktop computer, a laptop, and a server where I host my git repository. The goal for having this public repository is for me to be able to
program on my desktop, then push the changes to the server, and then
continue development on, say, my laptop later on grabbing the newer tree. Here's what I've done so far:
On the server, I've put all my programming projects. Then I did a:
git init && git add . && git commit -a
in one of my project directories.
I have a git-daemon running on this server so that people (me, for the most part :)) can pull my tree.
So on one of my two machines (desktop/laptop), I then clone the tree:
git clone git://my.server.com/project
It downloads the tree just fine. Then I go into the directory and start making changes. Here's an example:
---------------
>> on the desktop <<
~/temp rsmith$ git clone git://my.server.com/testing
Initialized empty Git repository in /home/rsmith/temp/testing/.git/
remote: Generating pack...
Done counting 3 objects.
Deltifying 3 objects...
remote: /3) done
Total 3 (delta 0), reused 0 (delta 0)
Indexing 3 objects.
100% (3/3) done
~/temp rsmith$ cd testing/
~/temp/testing rsmith$ ls
testing
~/temp/testing rsmith$ cat testing
This is a file that was created on the repository (server) machine...
~/temp/testing rsmith$ echo "I put this line in using the client (cloned) tree... I want to push this change up to the server that has the repo." >> testing
~/temp/testing rsmith$ cat testing
This is a file that was created on the repository (server) machine...
I put this line in using the client (cloned) tree... I want to push this change up to the server that has the repo.
~/temp/testing rsmith$ git commit -a
Created commit bae2b3e9a8d939cc3982b9ab398eb398eb29a13
1 files changed, 1 insertions(+), 0 deletions(-)
~/temp/testing rsmith$ git show
commit bae2b3e9a8d939cc3982b9ab398eb398eb29a13
Author: Robert Smith <wolf1boy79@yahoo.com>
Date: Sun Jun 17 13:54:59 2007 -0400
Added an extra line to the file...
diff --git a/testing b/testing
index ae22fbe..bae5e8f 100644
--- a/testing
+++ b/testing
@@ -1 +1,2 @@
This is a file that was created on the repository (server) machine...
+I put this line in using the client (cloned) tree... I want to push this change up to the server that has the repo.
---------------
Now I push the tree up to my repository...
>> on the desktop <<
~/temp/testing rsmith$ git push ssh://my.server.com/scm/git/testing master
Password:
updating 'refs/heads/master'
from b39be3baa3b29eb39e98bd92b3ab39bee3b3a291
to bae2b3e9a8d939cc3982b9ab398eb398eb29a13
Generating pack...
Done counting 5 objects.
Result has 3 objects.
Deltifying 3 objects.
100% (3/3) done
Writing 3 objects.
100% (3/3) done
Total 3 (delta 0), reused 0 (delta 0)
Unpacking 3 objects
refs/heads/master: b39be3baa3b29eb39e98bd92b3ab39bee3b3a291 -> bae2b3e9a8d939cc3982b9ab398eb398eb29a13
---------------
Now, on the SERVER (the machine with the repository that I pushed my tree to), I can see the changes by doing a "git show"...
~/scm/git/testing rsmith$ git show
commit bae2b3e9a8d939cc3982b9ab398eb398eb29a13
Author: Robert Smith <wolf1boy79@yahoo.com>
Date: Sun Jun 17 14:22:26 2007 -0400
Added an extra line to the file...
diff --git a/testing b/testing
index ae22fbe..bae5e8f 1206be
--- a/testing
+++ b/testing
@@ -1 +1,2 @@
This is a file that was created on the repository machine...
+I put this line in using the client (cloned) tree... I want to push this change up to the server that has the repo.
lines 1-13/13 (END)
HOWEVER, the testing file still doesn't show the change... (look below)
~/scm/git/testing rsmith$ cat testing
This is a file that was created on the repository machine...
So I figure I'll go ahead and commit the changes (since "git show" shows that the change has been pushed from the desktop to the server)... I go ahead and do a "git commit -a" on the SERVER...
commit b3eebe298b2399238a3becc9823b3982109ebea
Author: Robert Smith <wolf1boy79@yahoo.com>
Date: Sun Jun 17 14:34:11 2007 -0400
Testing.
diff --git a/testing b/testing
index b3ab382..3b32098a 102415
--- a/testing
+++ b/testing
@@ -1,2 +1 @@
This is a file that was created on the repository machine...
-I put this line in using the client (cloned) tree... I want to push this change up to the server that has the repo.
---------------
I'm not sure what I'm doing wrong. I see the change once the tree is pushed to the server (from the desktop), but it is undone automatically with a git commit -a. According to the documentation, everything up to the "push" step seems to be correct... But what do I do once I pushed the tree up to the public repo? How do I get those changes to be reflected on the public repo (the server?) without a git commit -a undoing those changes I've made?
Any ideas/help would be greatly appreciated.
- robert -
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Newbie using git -- need a little help
2007-06-17 18:55 Robert Smith
@ 2007-06-17 19:17 ` Thomas Glanzmann
2007-06-19 4:10 ` J. Bruce Fields
1 sibling, 0 replies; 5+ messages in thread
From: Thomas Glanzmann @ 2007-06-17 19:17 UTC (permalink / raw)
To: Robert Smith; +Cc: git
Hello Robert,
> I'm not sure what I'm doing wrong. I see the change once the tree is
> pushed to the server (from the desktop), but it is undone
> automatically with a git commit -a.
When you push to your server, the repository is updated (that is the
thing that is in .git) but your working tree isn't.
So when you push to a repository that also has a working tree attached
to it, you have to do a "git checkout" on the working tree. Or pull from
the repository and not push to it.
For a long time I did the same thing you did. I had a repository with a
working tree that I pushed into. I did it with bitkeeper and I did with
git. However these days I dropped that idea because it is not worth the
trouble (and it wasn't from the beginning) I just got used to it and did
not thought about it.
What I do now is the following:
On my laptop:
mkdir dir
git init
# add some files
git add .
git commit
Than I publish my project to the server without giving the repository at
the server a working directory attached to it. A working directory is
where you can edit files and commit changes locally, just in case I
didn't introduce the term yet.
# This creates the repository _without_ the working tree on the server.
ssh 131.188.30.102 git --git-dir=/home/cip/adm/sithglan/work/repositories/private/astro.git init-db
# This adds the remote origin to the config so that I don't have to
# type in the long repository path each time I am going to push or pull
# something.
git remote add origin 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git
# Now I publish my stuff to the central repository. You need at least
# one commit in order to be able to do that.
git push origin master:master
# I add a few lines to my config so that when I type in "git pull" it
#fetches the stuff and merges it with my local repositories master branch.
"vim .git/config" and add the following lines:
[branch "master"]
remote = origin
merge = refs/heads/master
EOF
# Now I can fetch back to see if everything works
git pull
Now I am fine the infrastructure is all set up. The next time I am going
to access the project from a different machine I simply do:
git pull 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git
And that's it. The origin and where it is going to merge stuff is set
automatically up by git. Note: I use ssh (attached to a ssh-agent so that I
don't have to passwords all the time I am doing a push or pull). I hope that
helps you and didn't miss your original question. I just fly over your e-Mail
and picked a few keywords to comment on.
Thomas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Newbie using git -- need a little help
2007-06-17 18:55 Robert Smith
2007-06-17 19:17 ` Thomas Glanzmann
@ 2007-06-19 4:10 ` J. Bruce Fields
1 sibling, 0 replies; 5+ messages in thread
From: J. Bruce Fields @ 2007-06-19 4:10 UTC (permalink / raw)
To: Robert Smith; +Cc: git
On Sun, Jun 17, 2007 at 11:55:52AM -0700, Robert Smith wrote:
> I've read over the documentation (the full manual) numerous times and
> must admit it's slightly overwhelming.
...
> I have both a desktop computer, a laptop, and a server where I host my
> git repository. The goal for having this public repository is for me
> to be able to program on my desktop, then push the changes to the
> server, and then continue development on, say, my laptop later on
> grabbing the newer tree.
Others answered your question, I think, so I was just trying to figure
out how to make that bit of the manual more helpful. Do you think
something like this would have saved you any time?
--b.
(Feedback like "I tried to figure out how to do X by reading Y, and
couldn't" is much appreciated, by the way--thanks.)
---
Documentation/user-manual.txt | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt
index e9da591..caa23c7 100644
--- a/Documentation/user-manual.txt
+++ b/Documentation/user-manual.txt
@@ -1772,7 +1772,7 @@ repository, but it works just as well in the other direction.
If you and the maintainer both have accounts on the same machine, then
you can just pull changes from each other's repositories directly;
-commands that accepts repository URLs as arguments will also accept a
+commands that accept repository URLs as arguments will also accept a
local directory name:
-------------------------------------------------
@@ -1780,6 +1780,15 @@ $ git clone /path/to/repository
$ git pull /path/to/other/repository
-------------------------------------------------
+or an ssh url:
+
+-------------------------------------------------
+$ git clone ssh://yourhost/~you/repository
+-------------------------------------------------
+
+For projects with few developers, or for synchronizing a few private
+repositories, this may be all you need.
+
However, the more common way to do this is to maintain a separate public
repository (usually on a different host) for others to pull changes
from. This is usually more convenient, and allows you to cleanly
@@ -1802,6 +1811,8 @@ like this:
| they push V
their public repo <------------------- their repo
+We explain how to do this in the following sections.
+
[[setting-up-a-public-repository]]
Setting up a public repository
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1913,6 +1924,12 @@ proceeding the branch name by a plus sign:
$ git push ssh://yourserver.com/~you/proj.git +master
-------------------------------------------------
+Note that the target of a "push" is normally a
+<<def_bare_repository,bare>> repository. You can also push to a
+repository that has a checked-out working tree, but the working tree
+will not be updated by the push. This may lead to unexpected results if
+the branch you push to is the currently checked-out branch.
+
As with git-fetch, you may also set up configuration options to
save typing; so, for example, after
--
1.5.2.2.238.g7cbf2f2
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-06-19 4:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-17 20:06 Newbie using git -- need a little help Robert Smith
2007-06-17 20:30 ` Thomas Glanzmann
-- strict thread matches above, loose matches on Subject: below --
2007-06-17 18:55 Robert Smith
2007-06-17 19:17 ` Thomas Glanzmann
2007-06-19 4:10 ` J. Bruce Fields
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 NNTP newsgroup(s).