{"thread":{"id":"11136","subject":"How to jump between two repositories ...","startedAt":"2007-12-05T05:59:57Z","lastAt":"2007-12-05T16:19:09Z","messageCount":10,"participants":["g2","Shawn O. Pearce","J. Bruce Fields","Väinö Järvelä","Steven Grimm","Andreas Ericsson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"61964","messageId":"C6AF7922-B2F7-42EB-B5DD-25353BC0AF2A@gmail.com","threadId":"11136","inReplyTo":null,"subject":"How to jump between two repositories ...","fromName":"g2","fromEmail":"gerald.gutierrez@gmail.com","sentAt":"2007-12-05T05:59:57Z","receivedAt":"2007-12-05T05:59:57Z","isPatch":false,"sender":{"key":"gerald.gutierrez@gmail.com","avatar":null},"body":"Hello all,\n\nI am currently working on some code at the office that I also want to  \nwork with at home. Seems like a good candidate for git. So I created a  \nrepository at work and did a \"git clone\" at home. I've run into some  \nstrange behaviour that I don't understand and would appreciate if  \nsomeone can clarify for me.\n\nImagine this scenario. At work:\ngit init\nedit test.c\ngit add test.c\ngit commit\n\nThen at home:\ngit clone <work git url>\nedit test.c\ngit commit -a\ngit push\n\nAt this point, I wanted to push my changes back to my work repository  \nso I can continue work the next day. So at home, I did a git push. I  \nexpect that my work repository has the newest material, but I find  \nthat when I do \"git status\" at work the next day, it tells me that my  \ntest.c is \"modified\" and has already staged it for commit. I need to  \ndo a \"git reset\" followed by \"git checkout\" to update my work folder  \nto the latest stuff.\n\nTotally different from my expectation of the repository knowing that  \nit is out of date and then kindly suggesting that I should do a \"git  \nupdate\" of some sort. What piece of understanding am I missing to  \nproperly \"get\" what is going on here, and how am I supposed to  \nproperly work with this setup?\n\nThanks for any help.\nGerald.\n"},{"id":"61965","messageId":"20071205061125.GE14735@spearce.org","threadId":"11136","inReplyTo":"C6AF7922-B2F7-42EB-B5DD-25353BC0AF2A@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-12-05T06:11:26Z","receivedAt":"2007-12-05T06:11:26Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"g2 <gerald.gutierrez@gmail.com> wrote:\n> At this point, I wanted to push my changes back to my work repository  \n> so I can continue work the next day. So at home, I did a git push. I  \n> expect that my work repository has the newest material, but I find  \n> that when I do \"git status\" at work the next day, it tells me that my  \n> test.c is \"modified\" and has already staged it for commit. I need to  \n> do a \"git reset\" followed by \"git checkout\" to update my work folder  \n> to the latest stuff.\n\nOddly enough, this question is asked so frequently that it is\nanswered in the GitFaq on the GitWiki:\n\n  http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73\n\n-- \nShawn.\n"},{"id":"61966","messageId":"20071205061425.GE11098@fieldses.org","threadId":"11136","inReplyTo":"C6AF7922-B2F7-42EB-B5DD-25353BC0AF2A@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-12-05T06:14:25Z","receivedAt":"2007-12-05T06:14:25Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Tue, Dec 04, 2007 at 09:59:57PM -0800, g2 wrote:\n> Hello all,\n>\n> I am currently working on some code at the office that I also want to work \n> with at home. Seems like a good candidate for git. So I created a \n> repository at work and did a \"git clone\" at home. I've run into some \n> strange behaviour that I don't understand and would appreciate if someone \n> can clarify for me.\n>\n> Imagine this scenario. At work:\n> git init\n> edit test.c\n> git add test.c\n> git commit\n>\n> Then at home:\n> git clone <work git url>\n> edit test.c\n> git commit -a\n> git push\n\nYou'll be much happier at this point if you ssh into work and then git\npull from home....\n\n> At this point, I wanted to push my changes back to my work repository so I \n> can continue work the next day. So at home, I did a git push. I expect that \n> my work repository has the newest material, but I find that when I do \"git \n> status\" at work the next day, it tells me that my test.c is \"modified\" and \n> has already staged it for commit. I need to do a \"git reset\" followed by \n> \"git checkout\" to update my work folder to the latest stuff.\n>\n> Totally different from my expectation of the repository knowing that it is \n> out of date and then kindly suggesting that I should do a \"git update\" of \n> some sort. What piece of understanding am I missing to properly \"get\" what \n> is going on here, and how am I supposed to properly work with this setup?\n\nGit doesn't support pushing to any branch that's checked out somewhere.\n\n--b.\n"},{"id":"61967","messageId":"3DD4D3BA-67B3-4AFC-AD24-799384D54408@pp.inet.fi","threadId":"11136","inReplyTo":"C6AF7922-B2F7-42EB-B5DD-25353BC0AF2A@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"Väinö Järvelä","fromEmail":"v@pp.inet.fi","sentAt":"2007-12-05T06:20:18Z","receivedAt":"2007-12-05T06:20:18Z","isPatch":false,"sender":{"key":"v@pp.inet.fi","avatar":null},"body":"On Dec 5, 2007, at 07:59, g2 wrote:\n\n> I am currently working on some code at the office that I also want  \n> to work with at home. Seems like a good candidate for git. So I  \n> created a repository at work and did a \"git clone\" at home. I've run  \n> into some strange behaviour that I don't understand and would  \n> appreciate if someone can clarify for me.\n>\n> Imagine this scenario. At work:\n> git init\n> edit test.c\n> git add test.c\n> git commit\n>\n> Then at home:\n> git clone <work git url>\n> edit test.c\n> git commit -a\n> git push\n>\n> At this point, I wanted to push my changes back to my work  \n> repository so I can continue work the next day. So at home, I did a  \n> git push. I expect that my work repository has the newest material,  \n> but I find that when I do \"git status\" at work the next day, it  \n> tells me that my test.c is \"modified\" and has already staged it for  \n> commit. I need to do a \"git reset\" followed by \"git checkout\" to  \n> update my work folder to the latest stuff.\n\nDid you clone a bare repository and push to it?\n\nHere is an excerpt from Git User's Manual:\n\"Note that the target of a \"push\" is normally a bare repository. You  \ncan also push to a repository that has a checked-out working tree, but  \nthe working tree will not be updated by the push. This may lead to  \nunexpected results if the branch you push to is the currently checked- \nout branch!\"\n\nSo to push to your work repository, you should create an intermediary  \nrepository between the work and home repositories. You can create it  \nby running:\n$ git clone --bare /git/work/ /git/work.git/\n\nThen you clone normally from the bare repository and pushing to it  \nworks fine. After you have pushed your changes to the bare repository,  \nyou'll have to pull them to the work repository to get the updates,  \njust like you would do with any public repository.\n\nAnother option would be to pull from your home repository to the work  \nrepository, if you can access your home computer from the work computer.\n\n--\nVäinö\n"},{"id":"61968","messageId":"33CB0252-20C7-4AF2-AEB3-2EAC20ED830B@gmail.com","threadId":"11136","inReplyTo":"3DD4D3BA-67B3-4AFC-AD24-799384D54408@pp.inet.fi","subject":"Re: How to jump between two repositories ...","fromName":"g2","fromEmail":"gerald.gutierrez@gmail.com","sentAt":"2007-12-05T06:44:27Z","receivedAt":"2007-12-05T06:44:27Z","isPatch":false,"sender":{"key":"gerald.gutierrez@gmail.com","avatar":null},"body":"\nWhat I am gathering from this is that I can use git in two ways: 1) as  \n\"just another svn\" bare git repository, or 2) only pull and don't  \npush, because push causes confusion. I'd be happy to only ever use  \npull, but I have one machine behind a firewall and can't pull. I can  \npush to a bare git repository like the svn model, but then I would  \njust use svn. What's the value of \"push\" then?\n\n\nOn 4-Dec-07, at 10:20 PM, Väinö Järvelä wrote:\n\n> On Dec 5, 2007, at 07:59, g2 wrote:\n>\n>> I am currently working on some code at the office that I also want  \n>> to work with at home. Seems like a good candidate for git. So I  \n>> created a repository at work and did a \"git clone\" at home. I've  \n>> run into some strange behaviour that I don't understand and would  \n>> appreciate if someone can clarify for me.\n>>\n>> Imagine this scenario. At work:\n>> git init\n>> edit test.c\n>> git add test.c\n>> git commit\n>>\n>> Then at home:\n>> git clone <work git url>\n>> edit test.c\n>> git commit -a\n>> git push\n>>\n>> At this point, I wanted to push my changes back to my work  \n>> repository so I can continue work the next day. So at home, I did a  \n>> git push. I expect that my work repository has the newest material,  \n>> but I find that when I do \"git status\" at work the next day, it  \n>> tells me that my test.c is \"modified\" and has already staged it for  \n>> commit. I need to do a \"git reset\" followed by \"git checkout\" to  \n>> update my work folder to the latest stuff.\n>\n> Did you clone a bare repository and push to it?\n>\n> Here is an excerpt from Git User's Manual:\n> \"Note that the target of a \"push\" is normally a bare repository. You  \n> can also push to a repository that has a checked-out working tree,  \n> but the working tree will not be updated by the push. This may lead  \n> to unexpected results if the branch you push to is the currently  \n> checked-out branch!\"\n>\n> So to push to your work repository, you should create an  \n> intermediary repository between the work and home repositories. You  \n> can create it by running:\n> $ git clone --bare /git/work/ /git/work.git/\n>\n> Then you clone normally from the bare repository and pushing to it  \n> works fine. After you have pushed your changes to the bare  \n> repository, you'll have to pull them to the work repository to get  \n> the updates, just like you would do with any public repository.\n>\n> Another option would be to pull from your home repository to the  \n> work repository, if you can access your home computer from the work  \n> computer.\n>\n> --\n> Väinö\n>\n"},{"id":"61971","messageId":"FE46507A-74FE-4EDE-AC28-96658B944182@midwinter.com","threadId":"11136","inReplyTo":"33CB0252-20C7-4AF2-AEB3-2EAC20ED830B@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-12-05T06:57:53Z","receivedAt":"2007-12-05T06:57:53Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"On Dec 4, 2007, at 10:44 PM, g2 wrote:\n> What I am gathering from this is that I can use git in two ways: 1)  \n> as \"just another svn\" bare git repository, or 2) only pull and don't  \n> push, because push causes confusion. I'd be happy to only ever use  \n> pull, but I have one machine behind a firewall and can't pull. I can  \n> push to a bare git repository like the svn model, but then I would  \n> just use svn. What's the value of \"push\" then?\n\nYou can push. Just don't push to a checked-out branch. I do exactly  \nwhat you're describing and it works fine. It looks something like this:\n\nserver% git checkout mybranch\nserver% edit somefile.c\nserver% git commit\n\nlaptop% git checkout mybranch\nlaptop% git pull\n   (with a pull configuration that pulls server's mybranch into  \nlaptop's)\nlaptop% edit somefile.c\nlaptop% git commit\nlaptop% git push server mybranch:laptop/mybranch\n\nserver% git checkout mybranch\nserver% git rebase laptop/mybranch\n\nPresto, ready to go. The trick is to push into a branch that's  \ndifferent from the one that's checked out, then rebase on top of that  \non the remote side after the push.\n\nYeah, it'd be nicer if you could just push to the checked-out branch  \ndirectly (and there are hooks to let you do that) but this is only  \nslightly awkward and it's easy once you've done it a few times.\n\n-Steve\n"},{"id":"61979","messageId":"198078A1-E2FC-4EA3-B353-0956E121F76C@pp.inet.fi","threadId":"11136","inReplyTo":"33CB0252-20C7-4AF2-AEB3-2EAC20ED830B@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"Väinö Järvelä","fromEmail":"v@pp.inet.fi","sentAt":"2007-12-05T07:32:20Z","receivedAt":"2007-12-05T07:32:20Z","isPatch":false,"sender":{"key":"v@pp.inet.fi","avatar":null},"body":"On Dec 5, 2007, at 08:44, g2 wrote:\n\n> What I am gathering from this is that I can use git in two ways: 1)  \n> as \"just another svn\" bare git repository, or 2) only pull and don't  \n> push, because push causes confusion. I'd be happy to only ever use  \n> pull, but I have one machine behind a firewall and can't pull. I can  \n> push to a bare git repository like the svn model, but then I would  \n> just use svn. What's the value of \"push\" then?\n\nI guess the value over svn, is in the excellent tools that Git  \nprovides (such as rebase, bisect and merging). And that you can  \ndevelop offline and still retain the individual commits.\n\nAnd you could use Steven Grimms solution, but I guess with that, you  \nneed to be careful to not leave your servers working tree on any of  \nyour laptop/ branch if you might push to one.\n\n--\nVäinö\n"},{"id":"61986","messageId":"47566526.9010900@op5.se","threadId":"11136","inReplyTo":"20071205061425.GE11098@fieldses.org","subject":"Re: How to jump between two repositories ...","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-12-05T08:45:26Z","receivedAt":"2007-12-05T08:45:26Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"J. Bruce Fields wrote:\n> On Tue, Dec 04, 2007 at 09:59:57PM -0800, g2 wrote:\n>> Hello all,\n>>\n>> I am currently working on some code at the office that I also want to work \n>> with at home. Seems like a good candidate for git. So I created a \n>> repository at work and did a \"git clone\" at home. I've run into some \n>> strange behaviour that I don't understand and would appreciate if someone \n>> can clarify for me.\n>>\n>> Imagine this scenario. At work:\n>> git init\n>> edit test.c\n>> git add test.c\n>> git commit\n>>\n>> Then at home:\n>> git clone <work git url>\n>> edit test.c\n>> git commit -a\n>> git push\n> \n> You'll be much happier at this point if you ssh into work and then git\n> pull from home....\n> \n>> At this point, I wanted to push my changes back to my work repository so I \n>> can continue work the next day. So at home, I did a git push. I expect that \n>> my work repository has the newest material, but I find that when I do \"git \n>> status\" at work the next day, it tells me that my test.c is \"modified\" and \n>> has already staged it for commit. I need to do a \"git reset\" followed by \n>> \"git checkout\" to update my work folder to the latest stuff.\n>>\n>> Totally different from my expectation of the repository knowing that it is \n>> out of date and then kindly suggesting that I should do a \"git update\" of \n>> some sort. What piece of understanding am I missing to properly \"get\" what \n>> is going on here, and how am I supposed to properly work with this setup?\n> \n> Git doesn't support pushing to any branch that's checked out somewhere.\n> \n\nYes it does. It just supports it badly. If there is a work-tree connected to\nthe receiving repository and that work-tree is pristine, it would be safe and\nsane to write the newly pushed changes to the connected working tree.\n\nWe do all our integration fixups by pushing to repositories with work-trees,\nsimply because it's ridiculously inconvenient to add the infrastructure to\npull to those repos from each individual developer. In that scenario, pushing\nto a checked out branch is highly useful and perfectly safe.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"62020","messageId":"9F403ACE-62C0-4A6D-945C-3DA6DF0316B8@gmail.com","threadId":"11136","inReplyTo":"47566526.9010900@op5.se","subject":"Re: How to jump between two repositories ...","fromName":"g2","fromEmail":"gerald.gutierrez@gmail.com","sentAt":"2007-12-05T15:28:02Z","receivedAt":"2007-12-05T15:28:02Z","isPatch":false,"sender":{"key":"gerald.gutierrez@gmail.com","avatar":null},"body":"\nHow do you safely push to the repository? Even if my receiving  \nrepository is pristine (the last command I do is a commit), after I  \npush into it, some files in the work-tree are effectively out of date  \nand git says so by thinking they are modified and staged for commit.  \nMy original set of example commands illustrates this. What set of  \ncommands do you use to avoid the problem?\n\n\nOn 5-Dec-07, at 12:45 AM, Andreas Ericsson wrote:\n>\n> Yes it does. It just supports it badly. If there is a work-tree  \n> connected to\n> the receiving repository and that work-tree is pristine, it would be  \n> safe and\n> sane to write the newly pushed changes to the connected working tree.\n>\n> We do all our integration fixups by pushing to repositories with  \n> work-trees,\n> simply because it's ridiculously inconvenient to add the  \n> infrastructure to\n> pull to those repos from each individual developer. In that  \n> scenario, pushing\n> to a checked out branch is highly useful and perfectly safe.\n>\n> -- \n> Andreas Ericsson                   andreas.ericsson@op5.se\n> OP5 AB                             www.op5.se\n> Tel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"62025","messageId":"4756CF7D.6090500@op5.se","threadId":"11136","inReplyTo":"9F403ACE-62C0-4A6D-945C-3DA6DF0316B8@gmail.com","subject":"Re: How to jump between two repositories ...","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2007-12-05T16:19:09Z","receivedAt":"2007-12-05T16:19:09Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"post\ntop-\ndon't\nPlease\n\ng2 wrote:\n> \n> How do you safely push to the repository? Even if my receiving \n> repository is pristine (the last command I do is a commit), after I push \n> into it, some files in the work-tree are effectively out of date and git \n> says so by thinking they are modified and staged for commit. My original \n> set of example commands illustrates this. What set of commands do you \n> use to avoid the problem?\n> \n\nVanilla git-push, ofcourse. I just make sure to run \"git reset --hard\" in\nthe receiving repo before using anything in it. Granted, it's \"safe\"\nbecause I know I never want to use any changes from those repos and not.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}