git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: git switch and restore user interface

From
Randall S. Becker <rsbecker@nexbridge.com>
Date
Aug 19, 2019, 10:51 UTC
Message-ID
<00f701d5567c$1d9fe810$58dfb830$@nexbridge.com>
In-Reply-To
<a3a66e58b1e44e88b9c11655c7c77e87@WCL-EX13MBX.wcl.local>
On August 19, 2019 5:41 AM, Ed Avis wrote:
> To: git@vger.kernel.org
> Subject: git switch and restore user interface
> 
> I think it would be helpful for git switch to print a reminder of the old
and
Show 10 quoted lines
> new branches.
> 
> Hi, a couple of suggestions for these experimental new commands.  Git
> switch should print the branch you are leaving:
> 
> % git switch foo
> You were previously on branch bar (abcdef).
> You are now on branch foo (bcdef0).
> 
> Sometimes I forget what branch I was on before and having it in the
terminal
> history would help a lot.
> 
> 
> For git restore, it might be worth splitting the command further, into
'safe
Show 15 quoted lines
> restore' and 'destructive restore'.  The safe command would always stop
> rather than lose data:
> 
> % git safe-restore .
> The following local changes would be overwritten:
>    Fee.c
>    Foe.c
> Stash them first, or (etc etc).
> 
> The command that unconditionally overwrites working copy changes should
> be given a different and more dangerous-sounding name.
> 
> The reason I suggest this is to make sure of a sensible answer to the
> newcomer's question: "I just deleted a file by mistake in my working copy,
> how do I get it back from git?".  Too often at the moment the answer is
"git
Show 5 quoted lines
> checkout ." which while correct is also much too dangerous to be a first
> resort.  There should be an obvious and safe command for restoring missing
> files without losing local changes.
> 
> In fact, I'd be quite happy for it to be like git clean, which in the
default
> configuration requires some flag like -f to make it lose any local
changes,
> even though the very purpose of git clean is to delete files.

I would be happier to have git restore --stash or some configuration option, like restore.stash=auto that has git automatically stash on a restore. But would the stash include everything or just the paths you are restoring? It might be nice to teach git clean the same option.

Cheers, Randall

Previous: Ed Avis
Message 2 of 2 in “git switch and restore user interface”
  1. Ed AvisAug 19, 2019
  2. Randall S. BeckerAug 19, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.