@@ -818,7 +818,113 @@ <h4>
818
818
< p class ="nutshell ">
819
819
< strong > In a nutshell</ strong > ,
820
820
you run < code > git rm</ code > to remove files from being tracked in Git. It
821
- will also remove them from your working directory.</ p >
821
+ will also remove them from your working directory.
822
+ </ p >
823
+
824
+ </ div >
825
+ </ div >
826
+
827
+ < div class ="box ">
828
+ < h2 >
829
+ < span class ="docs ">
830
+ < a href ="http://git-scm.com/docs/git-stash "> docs</ a >
831
+ < a href ="http://git-scm.com/book/en/Git-Tools-Stashing "> book</ a >
832
+ </ span >
833
+ < a name ="stash "> git stash</ a >
834
+ < span class ="desc "> save changes made in the current index and working directory for later</ span >
835
+ </ h2 >
836
+
837
+ < div class ="block ">
838
+
839
+ < p > You're in the middle of some changes but something comes up that you
840
+ need to jump over to, like a so-urgent-right-now bugfix, but don't want
841
+ to commit or lose your current edits. < code > git stash</ code > is there for you.
842
+ </ p >
843
+
844
+ < h4 >
845
+ git stash
846
+ < small > add current changes to the stack</ small >
847
+ </ h4 >
848
+
849
+ < p > Stashing takes the current state of the working directory and index,
850
+ puts it on a stack for later, and gives you back a clean working directory.
851
+ It will then leave you at the state of the last commit.
852
+ </ p >
853
+
854
+ < pre >
855
+ < b > $ git status -s</ b >
856
+ < span class ="red "> M</ span > hello.rb
857
+ < b > $ git stash</ b >
858
+ Saved working directory and index state WIP on master: 5857ac1 hello with a flower
859
+ HEAD is now at 5857ac1 hello with a flower
860
+ < b > $ git status</ b >
861
+ # On branch master
862
+ nothing to commit (working directory clean)
863
+ </ pre >
864
+
865
+ < h4 >
866
+ git stash list
867
+ < small > view stashes currently on the stack</ small >
868
+ </ h4 >
869
+
870
+ < p > It's helpful to know what you've got stowed on the stash and this is where
871
+ < code > git stash list</ code > comes in. Running this command will display a queue
872
+ of current stash items.
873
+ </ p >
874
+
875
+ < pre >
876
+ < b > $ git stash list</ b >
877
+ stash@{0}: WIP on master: 5857ac1 hello with a flower
878
+ </ pre >
879
+
880
+ < h4 >
881
+ git stash pop
882
+ < small > remove item from the list and apply to current working directory</ small >
883
+ </ h4 >
884
+
885
+ < p > After you've done the changes you were called away for, and you're ready to
886
+ continue from where you left off, run the < code > git stash pop</ code > command
887
+ to bring back the working directory to that state and remove it from the stash list.
888
+ </ p >
889
+
890
+ < pre >
891
+ < b > $ git stash pop</ b >
892
+ # On branch master
893
+ # Changes not staged for commit:
894
+ # (use "git add <file> ..." to update what will be committed)
895
+ # (use "git checkout -- <file> ..." to discard changes in working directory)
896
+ #
897
+ # < span class ="red "> modified: hello.rb</ span >
898
+ #
899
+ no changes added to commit (use "git add" and/or "git commit -a")
900
+ Dropped refs/stash@{0}: (14ddbc6f2c26330e33d08faf15d88f816b6cbd45)
901
+ </ pre >
902
+
903
+ < p > By default it will reapply the last added stash item to the working
904
+ directory. This will be the item referenced by < code > stash@{0}</ code > .
905
+ You can grab another stash item instead if you reference it in the arguments
906
+ list. For example, < code > git stash pop stash@{1}</ code > will apply the item
907
+ referenced by < code > stash@{1}</ code > .
908
+ </ p >
909
+
910
+ < p > If you want to leave the item on the stack, use
911
+ < code > git stash apply</ code > instead.
912
+ </ p >
913
+
914
+ < h4 >
915
+ git stash clear
916
+ < small > remove all items from the stash list</ small >
917
+ </ h4 >
918
+
919
+ < p > When you're done with the stash and/or you want to remove of all the
920
+ stored items, just run the < code > git stash clear</ code > command. But only
921
+ do this if you're sure you're done with the stash.
922
+ </ p >
923
+
924
+ < p class ="nutshell ">
925
+ < strong > In a nutshell</ strong > , run < code > git stash</ code > to quickly save
926
+ some changes that you're not ready to commit or save, but want to come
927
+ back to while you work on something else.
822
928
</ p >
823
929
824
930
</ div >
0 commit comments