{"thread":{"id":"52438","subject":"git checkout --autostash and git branch --autopop","startedAt":"2019-12-12T12:20:13Z","lastAt":"2019-12-14T12:59:03Z","messageCount":7,"participants":["rottis@fea.st","Denton Liu","Philip Oakley","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"388011","messageId":"8ab7d980-9584-4ce7-b4ee-9acac62c030c@www.fastmail.com","threadId":"52438","inReplyTo":null,"subject":"git checkout --autostash and git branch --autopop","fromName":"","fromEmail":"rottis@fea.st","sentAt":"2019-12-12T12:19:50Z","receivedAt":"2019-12-12T12:20:13Z","isPatch":false,"sender":{"key":"rottis@fea.st","avatar":null},"body":"Hello,\n\nI'm not sure if this has been discussed in the past, but I would like to humbly request this feature. Let me explain:\n\nSimilar to the 'git rebase --autostash', running 'git checkout --autostash' would automatically stash uncommitted changes for the\ncurrent branch.  then running 'git branch --autopop' would automatically apply an automatic stash when switching to a branch that had one.\n\nThank you.\n"},{"id":"388035","messageId":"20191212180901.GA35927@generichostname","threadId":"52438","inReplyTo":"8ab7d980-9584-4ce7-b4ee-9acac62c030c@www.fastmail.com","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-12-12T18:09:01Z","receivedAt":"2019-12-12T18:08:02Z","isPatch":false,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi rottis,\n\nOn Thu, Dec 12, 2019 at 02:19:50PM +0200, rottis@fea.st wrote:\n> Similar to the 'git rebase --autostash', running 'git checkout --autostash' would automatically stash uncommitted changes for the\n> current branch.  then running 'git branch --autopop' would automatically apply an automatic stash when switching to a branch that had one.\n\nI currently have a WIP version of this feature but I haven't had enough\ntime to polish it off (tests and docs). The last RFC round can be seen\nhere[1] if you want to test it out. It seems to work well enough for\npersonal use.\n\n[1]: https://lore.kernel.org/git/cover.1571246693.git.liu.denton@gmail.com/\n"},{"id":"388036","messageId":"20191212181244.GA36165@generichostname","threadId":"52438","inReplyTo":"20191212180901.GA35927@generichostname","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-12-12T18:12:44Z","receivedAt":"2019-12-12T18:11:44Z","isPatch":false,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On Thu, Dec 12, 2019 at 10:09:01AM -0800, Denton Liu wrote:\n> Hi rottis,\n> \n> On Thu, Dec 12, 2019 at 02:19:50PM +0200, rottis@fea.st wrote:\n> > Similar to the 'git rebase --autostash', running 'git checkout --autostash' would automatically stash uncommitted changes for the\n> > current branch.  then running 'git branch --autopop' would automatically apply an automatic stash when switching to a branch that had one.\n> \n> I currently have a WIP version of this feature but I haven't had enough\n> time to polish it off (tests and docs). The last RFC round can be seen\n> here[1] if you want to test it out. It seems to work well enough for\n> personal use.\n\nSorry, my mistake. I misread your message; my topic was for\n`git merge --autostash`. However, it does generalise the autostash\nmachinery so perhaps it'll be simpler to implement it into checkout in\nthe future, if that's desired?\n"},{"id":"388049","messageId":"e7850a51-4396-4698-ed98-62f991e33992@iee.email","threadId":"52438","inReplyTo":"20191212180901.GA35927@generichostname","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-12-12T22:02:14Z","receivedAt":"2019-12-12T22:02:18Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 12/12/2019 18:09, Denton Liu wrote:\n> Hi rottis,\n>\n> On Thu, Dec 12, 2019 at 02:19:50PM +0200, rottis@fea.st wrote:\n>> Similar to the 'git rebase --autostash', running 'git checkout --autostash' would automatically stash uncommitted changes for the\n>> current branch.  then running 'git branch --autopop' would automatically apply an automatic stash when switching to a branch that had one.\n> I currently have a WIP version of this feature but I haven't had enough\n> time to polish it off (tests and docs). The last RFC round can be seen\n> here[1] if you want to test it out. It seems to work well enough for\n> personal use.\n>\n> [1]: https://lore.kernel.org/git/cover.1571246693.git.liu.denton@gmail.com/\nIsn't this meant to be something similar to the --no-merge option for \ncheckout. That is: I am where I am, but really I want this to be on \nbranch X. Or is the --no-merge option meant to be something else?\n--\nPhilip\n"},{"id":"388122","messageId":"xmqq7e30m9i4.fsf@gitster-ct.c.googlers.com","threadId":"52438","inReplyTo":"e7850a51-4396-4698-ed98-62f991e33992@iee.email","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-13T17:16:19Z","receivedAt":"2019-12-13T20:39:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philip Oakley <philipoakley@iee.email> writes:\n\n> Isn't this meant to be something similar to the --no-merge option for\n> checkout. That is: I am where I am, but really I want this to be on\n> branch X. Or is the --no-merge option meant to be something else?\n\nIs there a --no-merge option to \"git checkout\"?  I know the reason\nwhy I invented \"git checkout --merge\" was because I wanted the\ncommand to carry more changes in the working tree than the default\nbehaviour would while checking out another branch, but I do not\nthink I added an option to do less, i.e. forbid it from carrying any\nchange in the working tree while checking out another branch.\n\n"},{"id":"388206","messageId":"2e2c7d89-d820-0643-61f9-11e74ab4ab9f@iee.email","threadId":"52438","inReplyTo":"xmqq7e30m9i4.fsf@gitster-ct.c.googlers.com","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-12-14T11:12:03Z","receivedAt":"2019-12-14T11:12:10Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 13/12/2019 17:16, Junio C Hamano wrote:\n> Philip Oakley <philipoakley@iee.email> writes:\n>\n>> Isn't this meant to be something similar to the --no-merge option for\n>> checkout. That is: I am where I am, but really I want this to be on\n>> branch X. Or is the --no-merge option meant to be something else?\n> Is there a --no-merge option to \"git checkout\"?  \nMy mistake. I misremembered or misunderstood. I'd been looking at both\ncheckout and branch man pages to see if there was a way out of the do\nthe 'rewind current branch and create new branch at current state'\ndance. I thought I'd seen 'no-merge' as a 'checkout -b' style option.\n\n> I know the reason\n> why I invented \"git checkout --merge\" was because I wanted the\n> command to carry more changes in the working tree than the default\n> behaviour would while checking out another branch, but I do not\n> think I added an option to do less, i.e. forbid it from carrying any\n> change in the working tree while checking out another branch.\nFor creating a new branch when in a dirty state (based on some other\nstart point than HEAD), there should be an option for numpties that have\nalready started digging the hole for themselves (stick's hand up\napologetically)...\n\nI was hoping that @rottis would clarify if his request has the same\nsymptoms.\n\n--\n\nPhilip\n"},{"id":"388207","messageId":"631f1c73-b85c-29f0-6259-5468dddcd0b8@iee.email","threadId":"52438","inReplyTo":"DA212C7D-D8D4-4E68-8C29-AF68364653E9@ssl-mail.com","subject":"Re: git checkout --autostash and git branch --autopop","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2019-12-14T12:58:59Z","receivedAt":"2019-12-14T12:59:03Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Eeli,\n thanks for the clarification\ncc'ing the list.\n\nOn 14/12/2019 11:58, Eeli wrote:\n> Often in my work I need to checkout my coworkers’ branches. When that happens, I will likely have some uncommitted changes I would need to commit or stash.\n>\n> This purely an ergonomic feature I’m suggesting.\n>\n> So instead of git stash or git commit -m ”wip” and later git stash pop or git reset HEAD~1, I could just run git checkout -b —autostash other-branch, do the work on the other branch and return to my previous state with git checkout —autopop my-branch.\nAlso, c/would a detached head (rather than using -b) be part of the\noptions if you are just doing a review?\n>\n> Apologies if I messed up my Git usage, I have used Git through Magit for too long.\n>\n>> On 14. Dec 2019, at 1.12 PM, Philip Oakley <philipoakley@iee.email> wrote:\n>>\n>> ﻿On 13/12/2019 17:16, Junio C Hamano wrote:\n>>> Philip Oakley <philipoakley@iee.email> writes:\n>>>\n>>>> Isn't this meant to be something similar to the --no-merge option for\n>>>> checkout. That is: I am where I am, but really I want this to be on\n>>>> branch X. Or is the --no-merge option meant to be something else?\n>>> Is there a --no-merge option to \"git checkout\"?  \n>> My mistake. I misremembered or misunderstood. I'd been looking at both\n>> checkout and branch man pages to see if there was a way out of the do\n>> the 'rewind current branch and create new branch at current state'\n>> dance. I thought I'd seen 'no-merge' as a 'checkout -b' style option.\n>>\n>>> I know the reason\n>>> why I invented \"git checkout --merge\" was because I wanted the\n>>> command to carry more changes in the working tree than the default\n>>> behaviour would while checking out another branch, but I do not\n>>> think I added an option to do less, i.e. forbid it from carrying any\n>>> change in the working tree while checking out another branch.\n>> For creating a new branch when in a dirty state (based on some other\n>> start point than HEAD), there should be an option for numpties that have\n>> already started digging the hole for themselves (stick's hand up\n>> apologetically)...\n>>\n>> I was hoping that @rottis would clarify if his request has the same\n>> symptoms.\n>>\n>> --\n>>\n>> Philip\n\n"}]}