Skip to content

Instantly share code, notes, and snippets.

@ton1517
Created October 19, 2013 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ton1517/7052468 to your computer and use it in GitHub Desktop.
Save ton1517/7052468 to your computer and use it in GitHub Desktop.
サクッと使いこなすためのgit stash Tips & stashの仕組み ref: http://qiita.com/ton1517/items/9888a78f6b063e748558
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: bar
#
# 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: hoge
#
$ git stash -k
$ ls -a
. .. .git bar hoge
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: bar
#
# 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: hoge
#
$ git stash
$ git stash pop
$ git status
# 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: bar
# modified: hoge
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git stash
$ git stash pop --index
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: bar
#
# 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: hoge
#
$ git stash list
stash@{0}: WIP on master: 8b7ca77 initial commit.
$ git log --graph stash@{0}
* commit ee5d8bdf21c6dfedb6b5a648241a20eff01b2418
|\ Merge: 8b7ca77 9dcce8a
| | Author: ton <tonton1517@gmail.com>
| | Date: Sat Oct 19 14:57:25 2013 +0900
| |
| | WIP on master: 8b7ca77 initial commit.
| |
| * commit 9dcce8af3e987391fcd1cdd2be95785b25c04944
|/ Author: ton <tonton1517@gmail.com>
| Date: Sat Oct 19 14:57:25 2013 +0900
|
| index on master: 8b7ca77 initial commit.
|
* commit 8b7ca77846392852f4c9b0304b16116369b712ce
Author: ton <tonton1517@gmail.com>
Date: Sat Oct 19 12:07:03 2013 +0900
initial commit.
*-. commit 90c6264e964f3dea2f7d418c49491a360630b387
|\ \ Merge: 8b7ca77 351051a 4ad4d67
| | | Author: ton <tonton1517@gmail.com>
| | | Date: Sat Oct 19 15:41:51 2013 +0900
| | |
| | | WIP on master: 8b7ca77 initial commit.
| | |
| | * commit 4ad4d67f4a8fd9e31da2f1e49c7f78f7b4db37f1
| | Author: ton <tonton1517@gmail.com>
| | Date: Sat Oct 19 15:41:51 2013 +0900
| |
| | untracked files on master: 8b7ca77 initial commit.
| |
| * commit 351051a076c5e0170acab6047dd15f67ac910fbe
|/ Author: ton <tonton1517@gmail.com>
| Date: Sat Oct 19 15:41:51 2013 +0900
|
| index on master: 8b7ca77 initial commit.
|
* commit 8b7ca77846392852f4c9b0304b16116369b712ce
Author: ton <tonton1517@gmail.com>
Date: Sat Oct 19 12:07:03 2013 +0900
initial commit.
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: bar
#
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: bar
#
# 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: hoge
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo
$ git stash -u
$ git status
# On branch master
nothing to commit, working directory clean
$ git status
# On branch master
nothing to commit, working directory clean
$ git ls-files
bar
hoge
$ ls -a
. .. .DS_Store .Trashes .directory .git bar hoge tags
$ git stash -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment