list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
From: "Theodore Ts'o" <>
To: Yuri <>
Cc: Felipe Contreras <>,
	Johannes Sixt <>,
	Git Mailing List <>
Subject: Re: [feature suggestion] Add 'git stash export', 'git stash import' commands to allow to backup stash externally
Date: Thu, 6 May 2021 10:10:25 -0400	[thread overview]
Message-ID: <YJP40YnfqTpKB9H/> (raw)
In-Reply-To: <>

On Thu, May 06, 2021 at 01:45:41AM -0700, Yuri wrote:
> So you advocate to use branches? If branches are same or better than stash,
> why was the stash feature created?
> Maybe it should be removed in favor of branches?

Stash is actually *implemented* in terms of a branch and reflogs.
It's syntactic sugar --- a user interface --- for a simple use case,
which is designed for use by users who don't care to learn a richer,
more complex set of commands, or who want to use for simple, temporary
use cases.

So you can see the top-most stash by running the command:

   git log refs/stash

You can also see that these two commands produce essentially the same

   git stash list
   git reflog refs/stash

By the way, reflogs by default expire after 90 days.  And if you do
something like this:

  git reflog expire --expire=now --all
  git stash list

*Poof* Watch all of your stashed patches disappear.  So if you are
storing things that you consider especially valuable using git stash,
I'd encourage you to rethink your strategy.

For anything that needs to be saved more than a few minutes, I tend to
create explicit branches, which can be named, so it's obvious is going
on.  Those branches aren't pushed out publically by default, any more
than the branch refs/stash is pushed out publically.  But because they
are branches, you can push them out explicitly, perhaps to a private
remote repo, if you like.

You can then use git cherry-pick, git rebase, git rebase -i, git
commit --amend, etc., to manage your work in progress.  This gives
much finer-grained control over how you manage your in-progress work,
at the cost of needing to learn a more complex set of commands.


					- Ted

P.S.  One hint: if the reason why you don't like using explicit branches is
because you get confused what branch you are on, it's helpful to put
your current branch on shell prompt.  I do something like this:

<tytso@cwcc> {/usr/projects/e2fsprogs/e2fsprogs}   (next)
1822% git checkout tt/pfsck
Switched to branch 'tt/pfsck'
<tytso@cwcc> {/usr/projects/e2fsprogs/e2fsprogs}   (tt/pfsck)

One of the conventions I use is that [initials]/* for branch names
that are generally never pushed out.  "tt" is my own initials, for my
own work.  Other people's initials are used for when they send me
branches to look at, that aren't quite ready to be merged into the
master, next, or maint branches.  Sometimes I will follow Junio's
convention of merging other people's in-progress work that they've
sent me into a pu (proposed updates) branch, for other people to test
and review, and for integration testing.  I tend not to do that often
since e2fsprogs' development tends not to be as complex/dynamic as

My shell prompt is accomplished through this in my .bashrc:

    if [ $UID = 0 ]; then
    if [ $SHLVL != 1 ]; then
	s=", level $SHLVL"
    if [ -n "$debian_chroot" ]; then
    if test -f /etc/bash_completion ; then
	. /etc/bash_completion
    if test -f /usr/local/share/bash-completion/ ; then
	. /usr/local/share/bash-completion/
    if test -f /usr/local/share/git-core/contrib/completion/ ; then
	. /usr/local/share/git-core/contrib/completion/
    if type __git_ps1 >& /dev/null ; then
	PS1="<${u}@${h}> {\${PWD}}$s  \$(__git_ps1)\n\!$p "
	PS1="<${u}@${h}> {\${PWD}}$s\n\!$p "
    unset u s h

      parent reply	other threads:[~2021-05-06 14:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 19:51 Yuri
2021-05-05 20:07 ` Randall S. Becker
2021-05-05 20:11   ` Yuri
2021-05-06  2:22   ` Junio C Hamano
2021-05-06  6:07 ` Johannes Sixt
2021-05-06  6:12   ` Yuri
2021-05-06  6:43     ` Johannes Sixt
2021-05-06  6:58       ` Yuri
2021-05-06  8:38         ` Junio C Hamano
2021-05-06  8:41           ` Yuri
2021-05-06  9:09             ` Junio C Hamano
2021-05-06 10:23             ` Felipe Contreras
2021-05-06  8:40         ` Felipe Contreras
2021-05-06  8:45           ` Yuri
2021-05-06 10:45             ` Felipe Contreras
2021-05-06 14:10             ` Theodore Ts'o [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YJP40YnfqTpKB9H/ \ \ \ \ \ \
    --subject='Re: [feature suggestion] Add '\''git stash export'\'', '\''git stash import'\'' commands to allow to backup stash externally' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).