automatically stash save/pop changes on git rebase?

Edit: As of Git version 1.8.4, but with an important side bug fixed in Git version 2.0.1, git rebase now has –autostash. You can configure git rebase to use –autostash by default as well, with git config –global rebase.autoStash true. Please note the following sentence from the documentation: However, use with care: the final stash … Read more

How can I rename a git stash?

Let’s assume your stash list looks like this: $ git stash list stash@{0}: WIP on master: Add some very important feature stash@{1}: WIP on master: Fix some silly bug First, you must remove stash entry which you want to rename: $ git stash drop stash@{1} Dropped stash@{1} (af8fdeee49a03d1b4609f294635e7f0d622e03db) Now just add it again with new … Read more

Stash changes to specific files

You can add the files with changes you want to keep, then stash the rest of the files and clear the stash: git add file2.cpp file2.h file3.cpp git stash –keep-index At this point, you’ve stashed your unwanted changes. If you’d like to permanently get rid of them, run: git stash drop Now you have file2.cpp, … Read more

How to reverse apply a stash?

According to the git-stash manpage, “A stash is represented as a commit whose tree records the state of the working directory, and its first parent is the commit at HEAD when the stash was created,” and git stash show -p gives us “the changes recorded in the stash as a diff between the stashed state … Read more

Git diff against a stash

See the most recent stash: git stash show -p See an arbitrary stash: git stash show -p stash@{1} From the git stash manpages: By default, the command shows the diffstat, but it will accept any format known to git diff (e.g., git stash show -p stash@{1} to view the second most recent stash in patch … Read more