Posts Git Stash
Post
Cancel

Git Stash

When you have made some modifications and want to achieve another tasks, I could be possible to save your modification by using stash.

git stash

Give a name to your stash by using the keyword save

git stash save 'name of my stash'

Use your last stash

git stash pop

List all your stash

git stash list

Unstash the last one (number 0)

git stash pop stash@{0}

Oups I delete my stash by using dropkeyword

Be careful ! if you use the drop keyword, it will clear and delete your stash

git stash drop stash@{0}

If you have used drop instead of pop, you still have a way to refund your changes.

When you use drop, you will see the hash in the terminal. By using the keyword apply, you should be able to apply your stash but it is not recreating it

git stash apply

If unfortunately, you have close your terminal, you can use the File System Consistency check to recover your hash.

git fsck --no-reflogs | awk '/dangling commit/ {print $3}'

You can also filter by date using the until and since arguments

git show --oneline --since='2018-09-01' --until='2018-10-01' $(git fsck --no-reflogs | awk '/dangling commit/ {print $3}')

This post is licensed under CC BY 4.0 by the author.