{"thread":{"id":"18986","subject":"Howto request: going home in the middle of something? v2009","startedAt":"2009-04-21T13:39:53Z","lastAt":"2009-04-21T17:05:15Z","messageCount":4,"participants":["Patrick Doyle","Mikael Magnusson","Michael Witten","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"111879","messageId":"e2a1d0aa0904210639t2ca73364pff26c85a0224182e@mail.gmail.com","threadId":"18986","inReplyTo":null,"subject":"Howto request: going home in the middle of something? v2009","fromName":"Patrick Doyle","fromEmail":"wpdster@gmail.com","sentAt":"2009-04-21T13:39:53Z","receivedAt":"2009-04-21T13:39:53Z","isPatch":false,"sender":{"key":"wpdster@gmail.com","avatar":null},"body":"Hello,\nI've developed a work habit of keeping my source code repository on a\nUSB stick and carrying that back and forth with me between work and\nhome.  (I typically have small, branchless, single-developer\nprojects.)  When I arrive at the other machine, I do\n\n$ git pull\n(code, commit, code, commit, etc...)\n$ git push\n\nOccasionally at the end of the day (if I'm at work) or at the end of\nthe night (if I'm at home), I'm in the middle of something that I want\nto continue, and I end up making a \"work-in-progress\" commit\n\n$ git commit -a \"WIP\"\n\njust so I can pull that in the next day/evening and continue where I\nleft off.  But that leaves a bunch of \"WIP\" commits in my history.  I\nstarted looking around for a better way to do this, and came across a\n2007 discussion (at\nhttp://kerneltrap.org/index.php?q=mailarchive/git/2007/10/18/347020/thread)\nwhere the OP really wanted (as do I) do be able to do something like\nthis:\n\n$ git stash\n$ git push\n$ git stash-push\n(travel to other site)\n$ git pull\n$ git stash-pull\n$ git stash apply\n(continue coding and committing as before)\n\nThere were a number of different suggestions, such as:\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\n... or using git-bundle\n\nThat discussion dates back to 2007.  Is there a new, improved, 2009\nway of accomplishing this?\n\n--wpd\n"},{"id":"111880","messageId":"237967ef0904210643m2b99dccapbfd10386128c478b@mail.gmail.com","threadId":"18986","inReplyTo":"e2a1d0aa0904210639t2ca73364pff26c85a0224182e@mail.gmail.com","subject":"Re: Howto request: going home in the middle of something? v2009","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2009-04-21T13:43:32Z","receivedAt":"2009-04-21T13:43:32Z","isPatch":false,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2009/4/21 Patrick Doyle <wpdster@gmail.com>:\n> Hello,\n> I've developed a work habit of keeping my source code repository on a\n> USB stick and carrying that back and forth with me between work and\n> home.  (I typically have small, branchless, single-developer\n> projects.)  When I arrive at the other machine, I do\n>\n> $ git pull\n> (code, commit, code, commit, etc...)\n> $ git push\n>\n> Occasionally at the end of the day (if I'm at work) or at the end of\n> the night (if I'm at home), I'm in the middle of something that I want\n> to continue, and I end up making a \"work-in-progress\" commit\n>\n> $ git commit -a \"WIP\"\n>\n> just so I can pull that in the next day/evening and continue where I\n> left off.  But that leaves a bunch of \"WIP\" commits in my history.  I\n> started looking around for a better way to do this, and came across a\n> 2007 discussion (at\n> http://kerneltrap.org/index.php?q=mailarchive/git/2007/10/18/347020/thread)\n> where the OP really wanted (as do I) do be able to do something like\n> this:\n>\n> $ git stash\n> $ git push\n> $ git stash-push\n> (travel to other site)\n> $ git pull\n> $ git stash-pull\n> $ git stash apply\n> (continue coding and committing as before)\n>\n> There were a number of different suggestions, such as:\n>\n> $ git commit -b temp -a -m \"Hold for transport home\"\n>\n> Then 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>\n> When 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>\n> ... or using git-bundle\n>\n> That discussion dates back to 2007.  Is there a new, improved, 2009\n> way of accomplishing this?\n>\n> --wpd\n\nman git-stash? or you can just git reset --soft HEAD^ away your wip commit.\n\n-- \nMikael Magnusson\n"},{"id":"111881","messageId":"b4087cc50904210647k7bcc1ecbob20ccf7b56047790@mail.gmail.com","threadId":"18986","inReplyTo":"e2a1d0aa0904210639t2ca73364pff26c85a0224182e@mail.gmail.com","subject":"Re: Howto request: going home in the middle of something? v2009","fromName":"Michael Witten","fromEmail":"mfwitten@gmail.com","sentAt":"2009-04-21T13:47:37Z","receivedAt":"2009-04-21T13:47:37Z","isPatch":false,"sender":{"key":"mfwitten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/597101?v=4"},"body":"On Tue, Apr 21, 2009 at 08:39, Patrick Doyle <wpdster@gmail.com> wrote:\n> But that leaves a bunch of \"WIP\" commits in my history.\n\nTake a look at git-rebase command, particularly the interactive\noption, -i; this allows you to rewrite the history by removing\ncommits, rearranging commits, and editing/amending commits.\n\nAlso, it seems like you're not branching enough.\n"},{"id":"111884","messageId":"alpine.LNX.1.00.0904211232550.10753@iabervon.org","threadId":"18986","inReplyTo":"e2a1d0aa0904210639t2ca73364pff26c85a0224182e@mail.gmail.com","subject":"Re: Howto request: going home in the middle of something? v2009","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2009-04-21T17:05:15Z","receivedAt":"2009-04-21T17:05:15Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Tue, 21 Apr 2009, Patrick Doyle wrote:\n\n> Hello,\n> I've developed a work habit of keeping my source code repository on a\n> USB stick and carrying that back and forth with me between work and\n> home.  (I typically have small, branchless, single-developer\n> projects.)  When I arrive at the other machine, I do\n> \n> $ git pull\n> (code, commit, code, commit, etc...)\n> $ git push\n> \n> Occasionally at the end of the day (if I'm at work) or at the end of\n> the night (if I'm at home), I'm in the middle of something that I want\n> to continue, and I end up making a \"work-in-progress\" commit\n> \n> $ git commit -a \"WIP\"\n> \n> just so I can pull that in the next day/evening and continue where I\n> left off.  But that leaves a bunch of \"WIP\" commits in my history.\n\nIn general, it can be useful to make a sequence of WIP commits which you \ndon't share with anyone else, and, when you've completed something, make \na sequence of nice clean commits.\n\nOne way to do that:\n\n$ git checkout -b wip # have a separate branch for the WIP\n$ git commit -m \"junk\" # this commit is total junk, but good hints\n$ git commit -m \"stuff\" # corrected a few things\n$ git commit -m \"going home\" # need to commit to have sometime to pull\n$ git commit -m \"finally working!\" # this is the first good state\n$ git checkout master # back on the real branch\n$ git diff master wip | git apply # get the good directory state\n$ git add -i # add only those changes that are a good first step\n$ git checkout . # get the working directory to match the first step\n$ make test # did you do it right?\n$ git commit # first production-quality commit\n$ git diff master wip | git apply # now get more changes\n...\n$ git diff master wip | git apply # get remaining changes\n$ git add -i # notice that the remainder are noise, debugging, etc.\n$ git branch -D wip # throw out the bad changes\n\nIn general, it's helpful to be able to commit any time you're about to \nmake a change to something you've already changed (because your second \nchange might not be as good as your first change), but then you want the \npublic history to come from a later pass where you already know what \nyou're doing and only make correct changes, so far as you can tell from \nhaving a working final result. It's like a painter doing a study before \nstarting to paint the real painting.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"}]}