From 3a8b9f0fc5397fb824cb49ecf6efd4a0c916b339 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Mon, 24 Nov 2014 19:32:40 -0600 Subject: Added 'git stash'! --- git.html.markdown | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'git.html.markdown') diff --git a/git.html.markdown b/git.html.markdown index 618d1906..e064122d 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -334,6 +334,55 @@ $ git push -u origin master $ git push ``` +### stash + +Stashing takes the dirty state of your working directory and saves it on a +stack of unfinished changes that you can reapply at any time. + +```bash +# Let's say you've been doing some work in your git repo, but you want to pull from the remote. +# Since you have dirty (uncommited) changes to some files, you are not able to run 'git pull'. +# Instead, you can run 'git stash' to save your changes onto a stack! + +$ git stash +Saved working directory and index state \ + "WIP on master: 049d078 added the index file" + HEAD is now at 049d078 added the index file + (To restore them type "git stash apply") + +# Now you can pull! +git pull +# ...changes apply... + +# Now check that everything is OK + +$ git status +# On branch master +nothing to commit, working directory clean + +# You can see what 'hunks' you've stashed so far: +# Since the 'hunks' are stored in a Last-In-First-Out stack +# our most recent change will be at top +$ git stash list +stash@{0}: WIP on master: 049d078 added the index file +stash@{1}: WIP on master: c264051 Revert "added file_size" +stash@{2}: WIP on master: 21d80a5 added number to log + +# Now let's apply our dirty changes back by popping them off the stack +# 'git stash apply' also works too +$ git stash pop +# On branch master +# Changes not staged for commit: +# (use "git add ..." to update what will be committed) +# +# modified: index.html +# modified: lib/simplegit.rb +# + +# Now you're good to go! + +[Additional Reading.](http://git-scm.com/book/en/v1/Git-Tools-Stashing) + ### rebase (caution) Take all changes that were committed on one branch, and replay them onto another branch. @@ -396,4 +445,4 @@ $ git rm /pather/to/the/file/HelloWorld.c * [GitGuys](http://www.gitguys.com/) -* [Git - the simple guide](http://rogerdudler.github.io/git-guide/index.html) \ No newline at end of file +* [Git - the simple guide](http://rogerdudler.github.io/git-guide/index.html) -- cgit v1.2.3 From 8b442c2497962b3b47844da74a416075313dc428 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Mon, 24 Nov 2014 19:39:44 -0600 Subject: Only bashified the code sections --- git.html.markdown | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'git.html.markdown') diff --git a/git.html.markdown b/git.html.markdown index e064122d..7778fdd4 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -336,40 +336,45 @@ $ git push ### stash -Stashing takes the dirty state of your working directory and saves it on a -stack of unfinished changes that you can reapply at any time. +Stashing takes the dirty state of your working directory and saves it on a stack of unfinished changes that you can reapply at any time. -```bash -# Let's say you've been doing some work in your git repo, but you want to pull from the remote. -# Since you have dirty (uncommited) changes to some files, you are not able to run 'git pull'. -# Instead, you can run 'git stash' to save your changes onto a stack! +Let's say you've been doing some work in your git repo, but you want to pull from the remote. +Since you have dirty (uncommited) changes to some files, you are not able to run 'git pull'. +Instead, you can run 'git stash' to save your changes onto a stack! +```bash $ git stash Saved working directory and index state \ "WIP on master: 049d078 added the index file" HEAD is now at 049d078 added the index file (To restore them type "git stash apply") +``` -# Now you can pull! +Now you can pull! +```bash git pull -# ...changes apply... +``` +...changes apply... -# Now check that everything is OK +Now check that everything is OK +```bash $ git status # On branch master nothing to commit, working directory clean +``` -# You can see what 'hunks' you've stashed so far: -# Since the 'hunks' are stored in a Last-In-First-Out stack -# our most recent change will be at top +You can see what 'hunks' you've stashed so far: +Since the 'hunks' are stored in a Last-In-First-Out stack our most recent change will be at top +```bash $ git stash list stash@{0}: WIP on master: 049d078 added the index file stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log +``` -# Now let's apply our dirty changes back by popping them off the stack -# 'git stash apply' also works too +Now let's apply our dirty changes back by popping them off the stack +```bash $ git stash pop # On branch master # Changes not staged for commit: @@ -378,9 +383,10 @@ $ git stash pop # modified: index.html # modified: lib/simplegit.rb # +``` +'git stash apply' also works too -# Now you're good to go! - +Now you're ready to get back to work on your stuff! [Additional Reading.](http://git-scm.com/book/en/v1/Git-Tools-Stashing) ### rebase (caution) -- cgit v1.2.3 From 295b40d2724a24e046f75da71b4e43124168b535 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Mon, 24 Nov 2014 19:41:02 -0600 Subject: Small formatting changes --- git.html.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'git.html.markdown') diff --git a/git.html.markdown b/git.html.markdown index 7778fdd4..7e9e70de 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -384,9 +384,10 @@ $ git stash pop # modified: lib/simplegit.rb # ``` -'git stash apply' also works too +`git stash apply` does the same thing Now you're ready to get back to work on your stuff! + [Additional Reading.](http://git-scm.com/book/en/v1/Git-Tools-Stashing) ### rebase (caution) -- cgit v1.2.3 From b7f4ca7ea8e831426eeced7b37b09ed1d81a8190 Mon Sep 17 00:00:00 2001 From: LOZORD Date: Mon, 24 Nov 2014 19:44:25 -0600 Subject: Added ourselves to the contributor section --- git.html.markdown | 2 ++ 1 file changed, 2 insertions(+) (limited to 'git.html.markdown') diff --git a/git.html.markdown b/git.html.markdown index 7e9e70de..f94fadee 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -3,6 +3,8 @@ category: tool tool: git contributors: - ["Jake Prather", "http://github.com/JakeHP"] + - ["Leo Rudberg" , "http://github.com/LOZORD"] + - ["Betsy Lorton" , "http://github.com/schbetsy"] filename: LearnGit.txt --- -- cgit v1.2.3 From 0e42f4c928b1414102467f539b313c1646e91093 Mon Sep 17 00:00:00 2001 From: Leo Rudberg Date: Tue, 25 Nov 2014 13:47:03 -0600 Subject: Fixed some markdown formatting issuses --- git.html.markdown | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'git.html.markdown') diff --git a/git.html.markdown b/git.html.markdown index f94fadee..04350dd5 100644 --- a/git.html.markdown +++ b/git.html.markdown @@ -341,8 +341,8 @@ $ git push Stashing takes the dirty state of your working directory and saves it on a stack of unfinished changes that you can reapply at any time. Let's say you've been doing some work in your git repo, but you want to pull from the remote. -Since you have dirty (uncommited) changes to some files, you are not able to run 'git pull'. -Instead, you can run 'git stash' to save your changes onto a stack! +Since you have dirty (uncommited) changes to some files, you are not able to run `git pull`. +Instead, you can run `git stash` to save your changes onto a stack! ```bash $ git stash @@ -353,10 +353,11 @@ Saved working directory and index state \ ``` Now you can pull! + ```bash git pull ``` -...changes apply... +`...changes apply...` Now check that everything is OK @@ -366,8 +367,9 @@ $ git status nothing to commit, working directory clean ``` -You can see what 'hunks' you've stashed so far: -Since the 'hunks' are stored in a Last-In-First-Out stack our most recent change will be at top +You can see what "hunks" you've stashed so far using `git stash list`. +Since the "hunks" are stored in a Last-In-First-Out stack, our most recent change will be at top. + ```bash $ git stash list stash@{0}: WIP on master: 049d078 added the index file @@ -375,7 +377,8 @@ stash@{1}: WIP on master: c264051 Revert "added file_size" stash@{2}: WIP on master: 21d80a5 added number to log ``` -Now let's apply our dirty changes back by popping them off the stack +Now let's apply our dirty changes back by popping them off the stack. + ```bash $ git stash pop # On branch master @@ -386,6 +389,7 @@ $ git stash pop # modified: lib/simplegit.rb # ``` + `git stash apply` does the same thing Now you're ready to get back to work on your stuff! -- cgit v1.2.3