stash meaning git 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 delete stash

git stash drop stash@{index}   // here index will be shown after getting stash list.

Example 3: git stash contnet

git stash show -p stash@{1}

Example 4: git stash

$ git stash list
stash@{0}: WIP on master: 049d078 Create index file
stash@{1}: WIP on master: c264051 Revert "Add file_size"
stash@{2}: WIP on master: 21d80a5 Add number to log

Example 5: git stash

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

Example 6: git stash

$ git status On branch master Changes to be committed: new file: style.css Changes not staged for commit: modified: index.html $ git stash Saved working directory and index state WIP on master: 5002d47 our new homepage HEAD is now at 5002d47 our new homepage $ git status On branch master nothing to commit, working tree clean