diff --git a/_layouts/reference.html b/_layouts/reference.html index f1ba9cf..ba90ddb 100755 --- a/_layouts/reference.html +++ b/_layouts/reference.html @@ -51,6 +51,7 @@
In a nutshell,
you run git rm
to remove files from being tracked in Git. It
- will also remove them from your working directory.
You're in the middle of some changes but something comes up that you
+ need to jump over to, like a so-urgent-right-now bugfix, but don't want
+ to commit or lose your current edits. git stash
is there for you.
+
Stashing takes the current state of the working directory and index, + puts it on a stack for later, and gives you back a clean working directory. + It will then leave you at the state of the last commit. +
+ +
+$ git status -s
+M hello.rb
+$ git stash
+Saved working directory and index state WIP on master: 5857ac1 hello with a flower
+HEAD is now at 5857ac1 hello with a flower
+$ git status
+# On branch master
+nothing to commit (working directory clean)
+
+
+ It's helpful to know what you've got stowed on the stash and this is where
+ git stash list
comes in. Running this command will display a queue
+ of current stash items.
+
+$ git stash list +stash@{0}: WIP on master: 5857ac1 hello with a flower ++ +
After you've done the changes you were called away for, and you're ready to
+ continue from where you left off, run the git stash pop
command
+ to bring back the working directory to that state and remove it from the stash list.
+
+$ git stash pop
+# On branch master
+# Changes not staged for commit:
+# (use "git add <file>..." to update what will be committed)
+# (use "git checkout -- <file>..." to discard changes in working directory)
+#
+# modified: hello.rb
+#
+no changes added to commit (use "git add" and/or "git commit -a")
+Dropped refs/stash@{0}: (14ddbc6f2c26330e33d08faf15d88f816b6cbd45)
+
+
+ By default it will reapply the last added stash item to the working
+ directory. This will be the item referenced by stash@{0}
.
+ You can grab another stash item instead if you reference it in the arguments
+ list. For example, git stash pop stash@{1}
will apply the item
+ referenced by stash@{1}
.
+
If you want to leave the item on the stack, use
+ git stash apply
instead.
+
When you're done with the stash and/or you want to remove of all the
+ stored items, just run the git stash clear
command. But only
+ do this if you're sure you're done with the stash.
+
+ In a nutshell, run git stash
to quickly save
+ some changes that you're not ready to commit or save, but want to come
+ back to while you work on something else.