|
|
Subscribe / Log in / New account

switch and restore

switch and restore

Posted Aug 19, 2019 9:42 UTC (Mon) by epa (subscriber, #39769)
In reply to: switch and restore by pclouds
Parent article: Git v2.23.0 released

Thanks, I sent a message to that address requesting some safe default behaviour for 'git restore' (a bit like 'git clean', which is safe by default despite its specific purpose of deleting local files). I also suggested that 'git switch' print out the old branch you are leaving, as a reminder for when you go back to it later.


to post comments

switch and restore

Posted Aug 19, 2019 12:17 UTC (Mon) by mathstuf (subscriber, #69389) [Link] (1 responses)

There is `git checkout -` (I imagine `git switch -` exists too) that checks out the previous branch (akin to `cd -` changing to `$OLDPWD`).

switch and restore

Posted Aug 19, 2019 15:49 UTC (Mon) by nybble41 (subscriber, #55106) [Link]

You can also look at the reflog. There will be a message like "HEAD@{xx}: checkout: moving from branchA to branchB", which is useful if you've changed branches multiple times.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds