git stash use code example

Example 1: git stash

# You can always retrieve stashed changes using `git stash`

git stash # To add changes to stash stack
git stash list # Shows list of stashed changes
git stash apply stash@{0} # Retrieve stash
git stash clear # Clear stash list

Example 2: git stash clean command

git stash clear

Example 3: git remove first stash

git stash drop 0

Example 4: get previous git stash

git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk

Example 5: git stash

//to restrict file to add for commit
git stash pathOfFile

Tags:

Misc Example