What are the equivalent commands in hg for git stash
, git stash apply
and git stash pop
?
Temporarily putting away your changes:
Mercurial
hg commit [-s]
is preferred
hg shelve
is not recommended
Git
git stash
Listing changes put away
Mercurial hg xl
or hg shelve -l
Git
git stash list
Viewing a put-away change
Mercurial
hg diff -c <rev>
or hg shelve -p <name>
Git
git stash show <name>
Restoring put-away changes
Mercurial
hg uncommit --no-keep
or hg unshelve
Git
git stash pop
Restoring put-away changes but keeping them in the stack
Mercurial
Continue to amend or
hg uncommit --keep
or
hg unshelve --keep
Git
git stash apply
I use the mq extension for this (which is not enabled by default). This extensions gives me the possibility to have a set of (not yet finished) patches, I keep on top of the "official" history.
What you would do with git stash
is now hg qnew »patchname« && hg qpop
, git stash pop
now becomes hg qpush
. The biggest directly noticeable difference is, that you have to give your patch a name in mercurial, while the git variant is happy to live anonymously.
Steve Losh did a more in depth article what this extension also can do.
© 2022 - 2024 — McMap. All rights reserved.
shelve
— also try a general search first. https://mcmap.net/q/386404/-hg-shelve-equivalent-of-git-stash-drop , markheath.net/post/git-stash-for-mercurial-users – Upbraidgit stash
is absurdly complicated andhg shelve
isn't, so you might not consider these "equivalent". – Spermato