{"thread":{"id":"8631","subject":"Newbie using git -- need a little help","startedAt":"2007-06-17T18:55:52Z","lastAt":"2007-06-19T04:10:28Z","messageCount":3,"participants":["Robert Smith","Thomas Glanzmann","J. Bruce Fields"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"45236","messageId":"42118.74778.qm@web57410.mail.re1.yahoo.com","threadId":"8631","inReplyTo":null,"subject":"Newbie using git -- need a little help","fromName":"Robert Smith","fromEmail":"wolf1boy79@yahoo.com","sentAt":"2007-06-17T18:55:52Z","receivedAt":"2007-06-17T18:55:52Z","isPatch":false,"sender":{"key":"wolf1boy79@yahoo.com","avatar":null},"body":"Hi,\n\nI 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).\n\nI 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\nprogram on my desktop, then push the changes to the server, and then\ncontinue development on, say, my laptop later on grabbing the newer tree.  Here's what I've done so far:\n\nOn the server, I've put all my programming projects.  Then I did a:\n\ngit init && git add . && git commit -a\n\nin one of my project directories.\n\nI have a git-daemon running on this server so that people (me, for the most part :)) can pull my tree.\n\nSo on one of my two machines (desktop/laptop), I then clone the tree:\n\ngit clone git://my.server.com/project\n\nIt downloads the tree just fine.  Then I go into the directory and start making changes.  Here's an example:\n\n---------------\n\n>> on the desktop <<\n\n~/temp rsmith$ git clone git://my.server.com/testing \nInitialized empty Git repository in /home/rsmith/temp/testing/.git/\nremote: Generating pack...\nDone counting 3 objects.\nDeltifying 3 objects...\nremote: /3) done\nTotal 3 (delta 0), reused 0 (delta 0)\nIndexing 3 objects.\n 100% (3/3) done\n\n~/temp rsmith$ cd testing/\n\n~/temp/testing rsmith$ ls\ntesting\n\n~/temp/testing rsmith$ cat testing \nThis is a file that was created on the repository (server) machine...\n\n~/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 \n\n~/temp/testing rsmith$ cat testing \nThis is a file that was created on the repository (server) machine...\nI put this line in using the client (cloned) tree...  I want to push this change up to the server that has the repo.\n\n~/temp/testing rsmith$ git commit -a\nCreated commit bae2b3e9a8d939cc3982b9ab398eb398eb29a13\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\n~/temp/testing rsmith$ git show\ncommit bae2b3e9a8d939cc3982b9ab398eb398eb29a13\nAuthor: Robert Smith <wolf1boy79@yahoo.com>\nDate:   Sun Jun 17 13:54:59 2007 -0400\n\n    Added an extra line to the file...\n\ndiff --git a/testing b/testing\nindex ae22fbe..bae5e8f 100644\n--- a/testing\n+++ b/testing\n@@ -1 +1,2 @@\n This is a file that was created on the repository (server) machine...\n+I put this line in using the client (cloned) tree...  I want to push this change up to the server that has the repo.\n\n---------------\n\nNow I push the tree up to my repository...\n\n>> on the desktop <<\n\n~/temp/testing rsmith$ git push ssh://my.server.com/scm/git/testing master\nPassword: \nupdating 'refs/heads/master'\n  from b39be3baa3b29eb39e98bd92b3ab39bee3b3a291\n  to   bae2b3e9a8d939cc3982b9ab398eb398eb29a13\nGenerating pack...\nDone counting 5 objects.\nResult has 3 objects.\nDeltifying 3 objects.\n 100% (3/3) done\nWriting 3 objects.\n 100% (3/3) done\nTotal 3 (delta 0), reused 0 (delta 0)\nUnpacking 3 objects\nrefs/heads/master: b39be3baa3b29eb39e98bd92b3ab39bee3b3a291 -> bae2b3e9a8d939cc3982b9ab398eb398eb29a13\n\n---------------\n\nNow, on the SERVER (the machine with the repository that I pushed my tree to), I can see the changes by doing a \"git show\"...\n\n~/scm/git/testing rsmith$ git show\ncommit bae2b3e9a8d939cc3982b9ab398eb398eb29a13\nAuthor: Robert Smith <wolf1boy79@yahoo.com>\nDate:   Sun Jun 17 14:22:26 2007 -0400\n\n    Added an extra line to the file...\n\ndiff --git a/testing b/testing\nindex ae22fbe..bae5e8f 1206be\n--- a/testing\n+++ b/testing\n@@ -1 +1,2 @@\n This is a file that was created on the repository machine...\n+I put this line in using the client (cloned) tree...  I want to push this change up to the server that has the repo.\nlines 1-13/13 (END)\n\n\nHOWEVER, the testing file still doesn't show the change...  (look below)\n\n~/scm/git/testing rsmith$ cat testing \nThis is a file that was created on the repository machine...\n\n\nSo 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...\n\ncommit b3eebe298b2399238a3becc9823b3982109ebea\nAuthor: Robert Smith <wolf1boy79@yahoo.com>\nDate:   Sun Jun 17 14:34:11 2007 -0400\n\n    Testing.\n\ndiff --git a/testing b/testing\nindex b3ab382..3b32098a 102415\n--- a/testing\n+++ b/testing\n@@ -1,2 +1 @@\n This is a file that was created on the repository machine...\n-I put this line in using the client (cloned) tree...  I want to push this change up to the server that has the repo.\n\n---------------\n\nI'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?\n\nAny ideas/help would be greatly appreciated.\n\n- robert -\n\n\n\n\n \n____________________________________________________________________________________\nBe a PS3 game guru.\nGet your game face on with the latest PS3 news and previews at Yahoo! Games.\nhttp://videogames.yahoo.com/platform?platform=120121\n"},{"id":"45237","messageId":"20070617191745.GD21291@cip.informatik.uni-erlangen.de","threadId":"8631","inReplyTo":"42118.74778.qm@web57410.mail.re1.yahoo.com","subject":"Re: Newbie using git -- need a little help","fromName":"Thomas Glanzmann","fromEmail":"thomas@glanzmann.de","sentAt":"2007-06-17T19:17:45Z","receivedAt":"2007-06-17T19:17:45Z","isPatch":false,"sender":{"key":"thomas@glanzmann.de","avatar":null},"body":"Hello Robert,\n\n> I'm not sure what I'm doing wrong.  I see the change once the tree is\n> pushed to the server (from the desktop), but it is undone\n> automatically with a git commit -a.\n\nWhen you push to your server, the repository is updated (that is the\nthing that is in .git) but your working tree isn't.\n\nSo when you push to a repository that also has a working tree attached\nto it, you have to do a \"git checkout\" on the working tree. Or pull from\nthe repository and not push to it.\n\nFor a long time I did the same thing you did. I had a repository with a\nworking tree that I pushed into. I did it with bitkeeper and I did with\ngit. However these days I dropped that idea because it is not worth the\ntrouble (and it wasn't from the beginning) I just got used to it and did\nnot thought about it.\n\nWhat I do now is the following:\n\nOn my laptop:\n\n        mkdir dir\n        git init\n        # add some files\n        git add .\n        git commit \n\nThan I publish my project to the server without giving the repository at\nthe server a working directory attached to it. A working directory is\nwhere you can edit files and commit changes locally, just in case I\ndidn't introduce the term yet.\n\n        # This creates the repository _without_ the working tree on the server.\n        ssh 131.188.30.102 git --git-dir=/home/cip/adm/sithglan/work/repositories/private/astro.git init-db\n\n        # This adds the remote origin to the config so that I don't have to\n        # type in the long repository path each time I am going to push or pull\n        # something.\n        git remote add origin 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git\n\n        # Now I publish my stuff to the central repository. You need at least\n        # one commit in order to be able to do that.\n        git push origin master:master\n\n\n        # I add a few lines to my config so that when I type in \"git pull\" it\n        #fetches the stuff and merges it with my local repositories master branch.\n\n        \"vim .git/config\" and add the following lines:\n\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\nEOF\n\n        # Now I can fetch back to see if everything works\n        git pull\n\nNow I am fine the infrastructure is all set up. The next time I am going\nto access the project from a different machine I simply do:\n\n        git pull 131.188.30.102:/home/cip/adm/sithglan/work/repositories/private/astro.git\n\nAnd that's it. The origin and where it is going to merge stuff is set\nautomatically up by git. Note: I use ssh (attached to a ssh-agent so that I\ndon't have to passwords all the time I am doing a push or pull). I hope that\nhelps you and didn't miss your original question. I just fly over your e-Mail\nand picked a few keywords to comment on.\n\n        Thomas\n"},{"id":"45315","messageId":"20070619041028.GG2825@fieldses.org","threadId":"8631","inReplyTo":"42118.74778.qm@web57410.mail.re1.yahoo.com","subject":"Re: Newbie using git -- need a little help","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-06-19T04:10:28Z","receivedAt":"2007-06-19T04:10:28Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Sun, Jun 17, 2007 at 11:55:52AM -0700, Robert Smith wrote:\n> I've read over the documentation (the full manual) numerous times and\n> must admit it's slightly overwhelming.\n...\n> I have both a desktop computer, a laptop, and a server where I host my\n> git repository.  The goal for having this public repository is for me\n> to be able to program on my desktop, then push the changes to the\n> server, and then continue development on, say, my laptop later on\n> grabbing the newer tree.\n\nOthers answered your question, I think, so I was just trying to figure\nout how to make that bit of the manual more helpful.  Do you think\nsomething like this would have saved you any time?\n\n--b.\n\n(Feedback like \"I tried to figure out how to do X by reading Y, and\ncouldn't\" is much appreciated, by the way--thanks.)\n\n---\n Documentation/user-manual.txt |   19 ++++++++++++++++++-\n 1 files changed, 18 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex e9da591..caa23c7 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -1772,7 +1772,7 @@ repository, but it works just as well in the other direction.\n \n If you and the maintainer both have accounts on the same machine, then\n you can just pull changes from each other's repositories directly;\n-commands that accepts repository URLs as arguments will also accept a\n+commands that accept repository URLs as arguments will also accept a\n local directory name:\n \n -------------------------------------------------\n@@ -1780,6 +1780,15 @@ $ git clone /path/to/repository\n $ git pull /path/to/other/repository\n -------------------------------------------------\n \n+or an ssh url:\n+\n+-------------------------------------------------\n+$ git clone ssh://yourhost/~you/repository\n+-------------------------------------------------\n+\n+For projects with few developers, or for synchronizing a few private\n+repositories, this may be all you need.\n+\n However, the more common way to do this is to maintain a separate public\n repository (usually on a different host) for others to pull changes\n from.  This is usually more convenient, and allows you to cleanly\n@@ -1802,6 +1811,8 @@ like this:\n         |               they push             V\n   their public repo <------------------- their repo\n \n+We explain how to do this in the following sections.\n+\n [[setting-up-a-public-repository]]\n Setting up a public repository\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n@@ -1913,6 +1924,12 @@ proceeding the branch name by a plus sign:\n $ git push ssh://yourserver.com/~you/proj.git +master\n -------------------------------------------------\n \n+Note that the target of a \"push\" is normally a\n+<<def_bare_repository,bare>> repository.  You can also push to a\n+repository that has a checked-out working tree, but the working tree\n+will not be updated by the push.  This may lead to unexpected results if\n+the branch you push to is the currently checked-out branch.\n+\n As with git-fetch, you may also set up configuration options to\n save typing; so, for example, after\n \n-- \n1.5.2.2.238.g7cbf2f2\n"}]}