{"thread":{"id":"10356","subject":"Howto request: going home in the middle of something?","startedAt":"2007-10-18T09:44:22Z","lastAt":"2007-10-24T13:44:14Z","messageCount":11,"participants":["Jan Wielemaker","Johannes Sixt","Karl Hasselström","Petr Baudis","Andy Parkins","Johannes Schindelin","Jing Xue","Matthias Kestenholz"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"56379","messageId":"200710181144.22655.wielemak@science.uva.nl","threadId":"10356","inReplyTo":null,"subject":"Howto request: going home in the middle of something?","fromName":"Jan Wielemaker","fromEmail":"wielemak@science.uva.nl","sentAt":"2007-10-18T09:44:22Z","receivedAt":"2007-10-18T09:44:22Z","isPatch":false,"sender":{"key":"wielemak@science.uva.nl","avatar":null},"body":"Hi,\n\nI've somewhere seen it in a mail, but I can't find it anymore. I have a\nbare central (public) repository and clones on various machines I work\non. We all know it, you're right in the middle of something and it is\nreally time to go home. You want to pick up your work at home, but\nwithout pushing to the shared repository.\n\nI'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess\nIdeally I want \"git stash\" at work, transfer the stashed changes to my\nother machine and apply them.  How do I do that?\n\nAlternatively, I guess, one can commit at machine A, fetch the commit\nfrom machine A and continue. I'm still too uncertain about the remote\naccess options to work this out properly, but it also feels less\nclean.\n\nHow do you deal with this?\n\n\tThanks --- Jan\n"},{"id":"56383","messageId":"4717377E.1010604@viscovery.net","threadId":"10356","inReplyTo":"200710181144.22655.wielemak@science.uva.nl","subject":"Re: Howto request: going home in the middle of something?","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-10-18T10:37:50Z","receivedAt":"2007-10-18T10:37:50Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jan Wielemaker schrieb:\n> I've somewhere seen it in a mail, but I can't find it anymore. I have a\n> bare central (public) repository and clones on various machines I work\n> on. We all know it, you're right in the middle of something and it is\n> really time to go home. You want to pick up your work at home, but\n> without pushing to the shared repository.\n> \n> I'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess\n> Ideally I want \"git stash\" at work, transfer the stashed changes to my\n> other machine and apply them.  How do I do that?\n\nOne way is to use a bundle:\n\n$ git checkout -b home\n$ git bundle create home.bdl origin..home\n\nThen put home.bdl on or USB stick or send by email. At home:\n\n$ git fetch home.bdl home\n$ git checkout -b to-be-continued FETCH_HEAD\n\nYou better make double sure that the commit \"origin\" that is used above is \navailable at home.\n\nJudge yourself whether this is \"elegant\".\n\n-- Hannes\n"},{"id":"56384","messageId":"20071018110726.GA3936@diana.vm.bytemark.co.uk","threadId":"10356","inReplyTo":"4717377E.1010604@viscovery.net","subject":"Re: Howto request: going home in the middle of something?","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2007-10-18T11:07:26Z","receivedAt":"2007-10-18T11:07:26Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2007-10-18 12:37:50 +0200, Johannes Sixt wrote:\n\n> Jan Wielemaker schrieb:\n>\n> > I've somewhere seen it in a mail, but I can't find it anymore. I\n> > have a bare central (public) repository and clones on various\n> > machines I work on. We all know it, you're right in the middle of\n> > something and it is really time to go home. You want to pick up\n> > your work at home, but without pushing to the shared repository.\n> >\n> > I'm sure GIT can do this elegantly, but I'm not yet sure how. I\n> > guess Ideally I want \"git stash\" at work, transfer the stashed\n> > changes to my other machine and apply them. How do I do that?\n>\n> One way is to use a bundle:\n\nAnother way is to push the unfinished changes to a temp branch, either\nat the same central repository if it's acceptable for people to have\ntemp branches there, or at another repository where temp branches\n_are_ permitted. All you need to set up a private repository for\nyourself is an ssh account somewhere. Or you could store the\nrepository on an usb stick.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"56386","messageId":"20071018112758.GN18279@machine.or.cz","threadId":"10356","inReplyTo":"200710181144.22655.wielemak@science.uva.nl","subject":"Re: Howto request: going home in the middle of something?","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-10-18T11:27:58Z","receivedAt":"2007-10-18T11:27:58Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Thu, Oct 18, 2007 at 11:44:22AM +0200, Jan Wielemaker wrote:\n> I've somewhere seen it in a mail, but I can't find it anymore. I have a\n> bare central (public) repository and clones on various machines I work\n> on. We all know it, you're right in the middle of something and it is\n> really time to go home. You want to pick up your work at home, but\n> without pushing to the shared repository.\n> \n> I'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess\n> Ideally I want \"git stash\" at work, transfer the stashed changes to my\n> other machine and apply them.  How do I do that?\n> \n> Alternatively, I guess, one can commit at machine A, fetch the commit\n> from machine A and continue. I'm still too uncertain about the remote\n> access options to work this out properly, but it also feels less\n> clean.\n\n  this should be pretty simple assuming SSH access to machine A. Git can\nfetch over SSH, so it's merely about telling it that repository X is\navailable over ssh over there and it'll fetch it home.\n\n  The exact setup depends on whether you want to do this just once or\nsemi-regularily.  If the former, just\n\n\tgit pull git+ssh://a.machine.aero/absolute/path\n\nNote that this should fetch only the remote master branch, if I'm not\nmistaken.\n\n  If the latter, tell your home repository about your work repository:\n\n\tgit remote add workrepo git+ssh://a.machine.aero/absolute/path\n\n  Then, you can anytime just\n\n\tgit fetch workrepo\n\nand it will fetch all the branches from workrepo; whether you want to\nuse git fetch and git merge or git pull depends on your local\narrangement of branches at home.\n\n\n  So, basically, when fetching you deal with your work repository\nexactly the same way as in the shared repository.\n\n  When pushing, this is not so trivial. Git _allows_ you to just push to\nyour work repository, but if you push to a branch that is currently\nchecked out, unexpected things will happen - always avoid that. If you\ncan fetch from home at work, do. If not, at least push to a branch at\nwork that can never be checked out and is reserved for that purpose.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nEarly to rise and early to bed makes a male healthy and wealthy and dead.\n                -- James Thurber\n"},{"id":"56387","messageId":"200710181229.07106.andyparkins@gmail.com","threadId":"10356","inReplyTo":"200710181144.22655.wielemak@science.uva.nl","subject":"Re: Howto request: going home in the middle of something?","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-10-18T11:29:03Z","receivedAt":"2007-10-18T11:29:03Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Thursday 2007 October 18, Jan Wielemaker wrote:\n\n> I've somewhere seen it in a mail, but I can't find it anymore. I have a\n> bare central (public) repository and clones on various machines I work\n> on. We all know it, you're right in the middle of something and it is\n> really time to go home. You want to pick up your work at home, but\n> without pushing to the shared repository.\n>\n> I'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess\n> Ideally I want \"git stash\" at work, transfer the stashed changes to my\n> other machine and apply them.  How do I do that?\n>\n> Alternatively, I guess, one can commit at machine A, fetch the commit\n> from machine A and continue. I'm still too uncertain about the remote\n> access options to work this out properly, but it also feels less\n> clean.\n>\n> How do you deal with this?\n\nI have two remotes (typically) in my .git/config.  One for the real central \nrepository and one for the alternate computer.  The two locations (say home \nand work) list the other as a remote.\n\nSo; before I go home I do this:\n\n git commit -b temp -a -m \"Hold for transport home\"\n\nThen when I get home I do this:\n\n git fetch work\n git merge work/temp\n git reset HEAD^\n # code code code\n git commit -b temp -a -m \"Hold for transport to work\"\n\nWhen I'm finished at home and want to carry on at work:\n\n git fetch --force home\n git merge home/temp\n git reset HEAD^\n # start coding for the day\n\nObviously if you do this repeatedly you'd need to tidy up the left over temp \nbranches, or ensure that your remote configurations list \"+\" in the fetch \nlines.  You can also use pushes instead of fetches if you're that way \ninclined, or you have a connection problem in one direction because of a \nfirewall.\n\nIt's slightly inelegant but it does ensure that nothing is ever accidentally \nlost by overwriting new with newer, which happened a few times in the days \nwhen I used rsync for copying the working directory between computers.\n\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIET\nandyparkins@gmail.com\n"},{"id":"56841","messageId":"200710221044.24191.wielemak@science.uva.nl","threadId":"10356","inReplyTo":"20071018112758.GN18279@machine.or.cz","subject":"Re: Howto request: going home in the middle of something?","fromName":"Jan Wielemaker","fromEmail":"wielemak@science.uva.nl","sentAt":"2007-10-22T08:44:24Z","receivedAt":"2007-10-22T08:44:24Z","isPatch":false,"sender":{"key":"wielemak@science.uva.nl","avatar":null},"body":"Thanks for the replies.\t I think I can live with something like this\n\n\t<work, in the middle of something>\n\t$ git checkout -b home\n\t$ git commit\n\t$ git checkout master\n\t<arriving at home>\n\t$ git jan@work:repo fetch home:home\t(using ssh)\n\t$ git checkout home\n\t<continue editing>\n\t$ git commit --amend\n\t$ git checkout master\n\t$ git merge home\n\t$ git -d home\n\t$ git commit\n\t$ git push\n\t<arriving at work>\n\t$ git -d home\n\t$ git pull\n\nIts still a bit many commands and you have to be aware what you are\ndoing for quite a while, but it does provide one single clean commit\nmessage, doesn't change the shared repo until all is finished and allows\nto abandon all work without leaving traces.\n\nPersonally I'd be more happy with\n\n\t<work, in the middle of something>\n\t$ git stash\n\t<arriving at home>\n\t$ git stash fetch jan@work{0}\t(well, some sensible syntax)\n\t$ git stash apply\n\t<continue editing>\n\t$ git commit\n\t$ git push\n\t<arriving at work>\n\t$ git pull\n\nIts not only shorter, but reduces the risc to make mistakes. I think the\nmissing fetch to copy the stashed data from work to home is actually\nthere if you know a bit more about git internals. Right? Ideally, this\ncould be combined in a little command that will simply move the\nuncommitted work from one clone to another, provided you have ssh access\nto the machine from which you want to fetch the work.\n\n\t--- Jan\n\nOn Thursday 18 October 2007 13:27, Petr Baudis wrote:\n> On Thu, Oct 18, 2007 at 11:44:22AM +0200, Jan Wielemaker wrote:\n> > I've somewhere seen it in a mail, but I can't find it anymore. I have a\n> > bare central (public) repository and clones on various machines I work\n> > on. We all know it, you're right in the middle of something and it is\n> > really time to go home. You want to pick up your work at home, but\n> > without pushing to the shared repository.\n> >\n> > I'm sure GIT can do this elegantly, but I'm not yet sure how.  I guess\n> > Ideally I want \"git stash\" at work, transfer the stashed changes to my\n> > other machine and apply them.  How do I do that?\n> >\n> > Alternatively, I guess, one can commit at machine A, fetch the commit\n> > from machine A and continue. I'm still too uncertain about the remote\n> > access options to work this out properly, but it also feels less\n> > clean.\n>\n>   this should be pretty simple assuming SSH access to machine A. Git can\n> fetch over SSH, so it's merely about telling it that repository X is\n> available over ssh over there and it'll fetch it home.\n>\n>   The exact setup depends on whether you want to do this just once or\n> semi-regularily.  If the former, just\n>\n> \tgit pull git+ssh://a.machine.aero/absolute/path\n>\n> Note that this should fetch only the remote master branch, if I'm not\n> mistaken.\n>\n>   If the latter, tell your home repository about your work repository:\n>\n> \tgit remote add workrepo git+ssh://a.machine.aero/absolute/path\n>\n>   Then, you can anytime just\n>\n> \tgit fetch workrepo\n>\n> and it will fetch all the branches from workrepo; whether you want to\n> use git fetch and git merge or git pull depends on your local\n> arrangement of branches at home.\n>\n>\n>   So, basically, when fetching you deal with your work repository\n> exactly the same way as in the shared repository.\n>\n>   When pushing, this is not so trivial. Git _allows_ you to just push to\n> your work repository, but if you push to a branch that is currently\n> checked out, unexpected things will happen - always avoid that. If you\n> can fetch from home at work, do. If not, at least push to a branch at\n> work that can never be checked out and is reserved for that purpose.\n"},{"id":"56860","messageId":"Pine.LNX.4.64.0710221230130.25221@racer.site","threadId":"10356","inReplyTo":"200710221044.24191.wielemak@science.uva.nl","subject":"Re: Howto request: going home in the middle of something?","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-22T11:32:43Z","receivedAt":"2007-10-22T11:32:43Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 22 Oct 2007, Jan Wielemaker wrote:\n\n> Thanks for the replies.\t I think I can live with something like this\n> \n> \t<work, in the middle of something>\n> \t$ git checkout -b home\n> \t$ git commit\n> \t$ git checkout master\n> \t<arriving at home>\n> \t$ git jan@work:repo fetch home:home\t(using ssh)\n\nYou probably meant \"git fetch jan@work:repo home:home\".\n\n> \t$ git checkout home\n> \t<continue editing>\n> \t$ git commit --amend\n> \t$ git checkout master\n> \t$ git merge home\n> \t$ git -d home\n> \t$ git commit\n> \t$ git push\n> \t<arriving at work>\n> \t$ git -d home\n> \t$ git pull\n> \n> Its still a bit many commands and you have to be aware what you are\n> doing for quite a while, but it does provide one single clean commit\n> message, doesn't change the shared repo until all is finished and allows\n> to abandon all work without leaving traces.\n> \n> Personally I'd be more happy with\n> \n> \t<work, in the middle of something>\n> \t$ git stash\n> \t<arriving at home>\n> \t$ git stash fetch jan@work{0}\t(well, some sensible syntax)\n> \t$ git stash apply\n> \t<continue editing>\n> \t$ git commit\n> \t$ git push\n> \t<arriving at work>\n> \t$ git pull\n\nHappily, that is already possible:  However, instead of\n\n\tgit stash fetch jan@work{0}\n\nyou should say\n\n\tgit fetch jan@work stash:stash\n\nThis will only fetch the last stash, but that is what you wanted anyway, \nright?\n\nCiao,\nDscho\n\nP.S.: Since you top-posted, I just ignored the mail you quoted, assuming \nthat it was not relevant to your mail.\n"},{"id":"57009","messageId":"20071023135655.x6g6mln1j4880wog@intranet.digizenstudio.com","threadId":"10356","inReplyTo":"200710221044.24191.wielemak@science.uva.nl","subject":"Re: Howto request: going home in the middle of something?","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2007-10-23T17:56:55Z","receivedAt":"2007-10-23T17:56:55Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"\nQuoting Jan Wielemaker <wielemak@science.uva.nl>:\n\n> Thanks for the replies.\t I think I can live with something like this\n>\n> \t<work, in the middle of something>\n> \t$ git checkout -b home\n> \t$ git commit\n> \t$ git checkout master\n> \t<arriving at home>\n> \t$ git jan@work:repo fetch home:home\t(using ssh)\n> \t$ git checkout home\n> \t<continue editing>\n> \t$ git commit --amend\n> \t$ git checkout master\n> \t$ git merge home\n> \t$ git -d home\n> \t$ git commit\n> \t$ git push\n> \t<arriving at work>\n> \t$ git -d home\n> \t$ git pull\n>\n> Its still a bit many commands and you have to be aware what you are\n> doing for quite a while, but it does provide one single clean commit\n> message, doesn't change the shared repo until all is finished and allows\n> to abandon all work without leaving traces.\n\nWhat does the extra branch gain for us here? That's not a rhetorical  \nquestion, I'm actually curious to learn, because I always just commit,  \nswitch to another computer, pull, and reset HEAD^.\n\nThanks.\n-- \nJing Xue\n"},{"id":"57013","messageId":"200710232038.21206.wielemak@science.uva.nl","threadId":"10356","inReplyTo":"20071023135655.x6g6mln1j4880wog@intranet.digizenstudio.com","subject":"Re: Howto request: going home in the middle of something?","fromName":"Jan Wielemaker","fromEmail":"wielemak@science.uva.nl","sentAt":"2007-10-23T18:38:20Z","receivedAt":"2007-10-23T18:38:20Z","isPatch":false,"sender":{"key":"wielemak@science.uva.nl","avatar":null},"body":"On Tuesday 23 October 2007 19:56:55 Jing Xue wrote:\n> Quoting Jan Wielemaker <wielemak@science.uva.nl>:\n> > Thanks for the replies.\t I think I can live with something like this\n> >\n> > \t<work, in the middle of something>\n> > \t$ git checkout -b home\n> > \t$ git commit\n> > \t$ git checkout master\n> > \t<arriving at home>\n> > \t$ git jan@work:repo fetch home:home\t(using ssh)\n> > \t$ git checkout home\n> > \t<continue editing>\n> > \t$ git commit --amend\n> > \t$ git checkout master\n> > \t$ git merge home\n> > \t$ git -d home\n> > \t$ git commit\n> > \t$ git push\n> > \t<arriving at work>\n> > \t$ git -d home\n> > \t$ git pull\n> >\n> > Its still a bit many commands and you have to be aware what you are\n> > doing for quite a while, but it does provide one single clean commit\n> > message, doesn't change the shared repo until all is finished and allows\n> > to abandon all work without leaving traces.\n>\n> What does the extra branch gain for us here? That's not a rhetorical\n> question, I'm actually curious to learn, because I always just commit,\n> switch to another computer, pull, and reset HEAD^.\n\nI'm just trying to learn. Sofar I like the idea to stash and use\ngit-fetch to get the stash from the other side. As stash is about\nhandling current work, it feels as the most appropriate solution\nand is a lot shorter.\n\n\tCheers --- Jan\n"},{"id":"57024","messageId":"256C87B5-3ADE-4A96-9530-A45B97601BAA@spinlock.ch","threadId":"10356","inReplyTo":"20071023135655.x6g6mln1j4880wog@intranet.digizenstudio.com","subject":"Re: Howto request: going home in the middle of something?","fromName":"Matthias Kestenholz","fromEmail":"mk@spinlock.ch","sentAt":"2007-10-23T20:28:46Z","receivedAt":"2007-10-23T20:28:46Z","isPatch":false,"sender":{"key":"matthias@spinlock.ch","avatar":"https://gravatar.com/avatar/bc18f396e70163d09ab458a341b1decb7e8b6ee3aa2c0c954ec20162e67c4d46?d=mp&s=160"},"body":"Hi,\n\nOn 23.10.2007, at 19:56, Jing Xue wrote:\n> What does the extra branch gain for us here? That's not a  \n> rhetorical question, I'm actually curious to learn, because I  \n> always just commit, switch to another computer, pull, and reset HEAD^.\n\nIf someone tracks the main branch you are working on and fetches\nwhile you are travelling home, he has the WIP commit as a new tip\nin his tree.\nIf he bases further work upon the WIP commit, he'll need to rebase\nor merge his changes onto your new tip once you have amended or\nreplaced the commit. If you are working on the\nmaster branch, you should really avoid rewinding it. Rewinding topic\nbranches is ok, but a temporary branch is still better to clearly tell\npotential fetch-ers that this is only Work in Progress, and not meant\nto be published in the current state.\n\nMatthias\n\n-- \nhttp://spinlock.ch/blog/\n"},{"id":"57082","messageId":"20071024134414.GA15710@falcon.digizenstudio.com","threadId":"10356","inReplyTo":"256C87B5-3ADE-4A96-9530-A45B97601BAA@spinlock.ch","subject":"Re: Howto request: going home in the middle of something?","fromName":"Jing Xue","fromEmail":"jingxue@digizenstudio.com","sentAt":"2007-10-24T13:44:14Z","receivedAt":"2007-10-24T13:44:14Z","isPatch":false,"sender":{"key":"jingxue@digizenstudio.com","avatar":null},"body":"On Tue, Oct 23, 2007 at 10:28:46PM +0200, Matthias Kestenholz wrote:\n> Hi,\n\nHi,\n\n> If someone tracks the main branch you are working on and fetches\n> while you are travelling home, he has the WIP commit as a new tip\n> in his tree.\n> If he bases further work upon the WIP commit, he'll need to rebase\n> or merge his changes onto your new tip once you have amended or\n> replaced the commit. If you are working on the\n> master branch, you should really avoid rewinding it. Rewinding topic\n> branches is ok, but a temporary branch is still better to clearly tell\n> potential fetch-ers that this is only Work in Progress, and not meant\n> to be published in the current state.\n\nGood point. Although I guess if some workflow lets you directly hack on a\npublic branch, it can have lots of other issues beyond just the WIP\nbeing pulled accidentally, no?\n\nCheers.\n-- \nJing Xue\n"}]}