xxxxxxxxxx
# Stash your changes
git stash
# Optionally, you can provide a message to describe your stash
git stash save "Work in progress - feature XYZ"
# List all stashes
git stash list
# Apply a specific stash (by index)
git stash apply stash@{0}
# Drop a specific stash (by index)
git stash drop stash@{0}
# Apply and drop the most recent stash
git stash pop
# Apply and keep the stash (do not remove it)
git stash branch new-feature-branch
xxxxxxxxxx
# Stash a tracked file
git stash push -m "stash message" <fil_path>
# Stash all tracked files
git stash -m "stash message"
# If file is not tracked you have to add it first "git add <fil_path>"
xxxxxxxxxx
# To stash the changes
git stash
# To see the list of stashes
git stash list
# To apply the most recent stash
git stash apply
# To apply a specific stash
git stash apply stash@{<stashNumber>}
# To remove the most recent stash
git stash drop
# To remove a specific stash
git stash drop stash@{<stashNumber>}
# To apply and remove the most recent stash
git stash pop
# To apply and remove a specific stash
git stash pop stash@{<stashNumber>}
xxxxxxxxxx
// What is stash changes in git?
// git stash temporarily shelves (or stashes) changes you've made to your working copy
// so you can work on something else, and then come back and re-apply them later on.
git stash
xxxxxxxxxx
Git stash allows you to save your unfinished changes and revert back to a clean working directory. Here's how it works:
To stash your changes:
git stash
To list all stashed changes:
git stash list
To apply the most recent stash:
git stash apply
To apply a specific stash (identified by the stash index):
git stash apply stash@{<stash index>}
To remove the most recent stash without applying it:
git stash drop
To remove a specific stash without applying it:
git stash drop stash@{<stash index>}
To apply and remove the most recent stash:
git stash pop
To apply and remove a specific stash (identified by the stash index):
git stash pop stash@{<stash index>}