This is a simple post-checkout
git hook
that checks for stashes that may be on the current branch.
Git hooks aren't committed to the repo, so you'll need to install this hook in every repo where you want it, and on every collaborator's machine.
Automated installation
is simplest,
but if you already have a post-checkout
git hook,
you'll need to
install the hook manually.
You'll need curl installed to run this command.
cd
into your repo's root folder:
cd /path/to/your/repo/
Then run this command:
bash <(curl -s https://raw.githubusercontent.com/imnotashrimp/stashed-on-branch/master/install.sh)
- Copy the
post-checkout
script to your repo at
.git/hooks/post-checkout
. - Make the script executable by running
chmod +x /your/repo/path/.git/hooks/post-checkout
.
-
After installation, create a temporary branch:
git checkout -b DELETEME
-
Change a file, and then stash the changes:
git stash
-
Switch to a different branch:
git checkout master
-
And then switch back to the temporary branch:
git checkout DELETEME
If you see a list of stashes from the branch, everything's good. If not, double-check that the hook was installed in the repo at
.git/hooks/post-checkout
. -
When you're done, switch to another branch and delete the test branch:
git checkout master git branch -d DELETEME