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 output: 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. Cheers, - 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) 1823% 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 git's. My shell prompt is accomplished through this in my .bashrc: if [ $UID = 0 ]; then u="${LOGNAME}.root" p="#" else u="$LOGNAME"; p="%" fi if [ $SHLVL != 1 ]; then s=", level $SHLVL" fi h=${HOSTNAME} if [ -n "$debian_chroot" ]; then h=${debian_chroot}-CHROOT.${h} fi if test -f /etc/bash_completion ; then . /etc/bash_completion fi if test -f /usr/local/share/bash-completion/bash_completion.sh ; then . /usr/local/share/bash-completion/bash_completion.sh fi if test -f /usr/local/share/git-core/contrib/completion/git-prompt.sh ; then . /usr/local/share/git-core/contrib/completion/git-prompt.sh fi if type __git_ps1 >& /dev/null ; then PS1="<${u}@${h}> {\${PWD}}$s \$(__git_ps1)\n\!$p " else PS1="<${u}@${h}> {\${PWD}}$s\n\!$p " fi unset u s h