Last active
June 3, 2018 06:39
-
-
Save rakesh87/40a347f9a4e5dfb18330e637f1d6d38d to your computer and use it in GitHub Desktop.
Git Stash Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. git stash list | |
List out all stash entries that we have currently. stash entries are listed with name and latest entries first | |
ex: | |
git stash list | |
# example result | |
stash@{0}: On development: WIP README | |
stash@{1}: WIP on development: 1b78aaa7 | |
2. git stash OR git stash push | |
This command saves your local changes to new stash entry and moves back the local working directory to the remote head. | |
ex: | |
git stash push or git stash | |
# example result | |
Saved working directory and index state WIP on development: 1b78aaa7 change the | |
3. git stash pop | |
It removes the single last stashed state from the stash list and applies on top of the current working directory | |
4. git stash show | |
It show the diff between the latest stash and the last commit remote head when the stash was created. | |
ex: | |
git stash show | |
# example result | |
file_changed.yml | 2 ++ | |
1 file changed, 2 insertions(+) | |
You can provide a stash index as a parameter to show command | |
git stash show stash@{1} | |
# example result | |
file2_changed.yml | 15 ++ | |
1 file changed, 15 insertions(+) | |
5. git stash drop | |
This command removes single stash entry from the stashed list. It removes the latest stash from the list as a default behavior. | |
Ex: | |
git stash drop | |
# example result | |
Dropped refs/stash@{0} (2b62b0d78650811dfde32192a1996fb51d6d6858) | |
You can give a stash index as a parameter to drop | |
ex: | |
git stash drop stash@{1} | |
# example result | |
Dropped refs/stash@{1} (2b62b0d78650811dfde32192a1996fb51d6d6858) | |
6. git stash apply | |
It behaves same as git stash pop but keeps the stashed list unchanged | |
ex: | |
git stash apply | |
7. git stash clear | |
This command clears out all stash entries and stashed changes will be unrecoverable | |
ex: | |
git stash clear |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment