Спрятать измнения в индексе в тайник

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   b
#       new file:   c
#       new file:   d
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       e
$ git stash 
Saved working directory and index state WIP on master: 054daa6 initial commit
HEAD is now at 054daa6 initial commit
$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       e
nothing added to commit but untracked files present (use "git add" to track)

посмотреть содержимое тайника

$ git stash list 
stash@{0}: WIP on master: 054daa6 initial commit
stash@{1}: WIP on master: 054daa6 initial commit
stash@{2}: WIP on master: 054daa6 initial commit

Перейти к данным, что спрятаны в тайнике

$ git stash list
stash@{0}: WIP on master: 054daa6 initial commit
stash@{1}: WIP on master: 054daa6 initial commit
stash@{2}: WIP on master: 054daa6 initial commit
$ git checkout stash@{0}

Применить последние спрятанные в тайнике данные

$ git stash apply
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   index.html
#      modified:   lib/simplegit.rb

Применить последние спрятанные в тайнике данные и добавить их в индекс.

$ git stash apply --index
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#      modified:   index.html
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   lib/simplegit.rb

Удалить данные из стека, спрятанные в тайнике

$ 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
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)

Отменить изменения, внесенные командой stash apply

$ git stash show -p stash@{0} |git apply -R

Отменить последние изменения, внесенные командой stash apply

$ git stash show -p |git apply -R

Пример работы с гит stash

$ git status
Changed but not updated:
  modified:   b
  deleted:    c
  modified:   d

Untracked files:
  j
$ git add .
$ git stash
Saved working directory and index state WIP on master: b11a467 commit 1
HEAD is now at b11a467 commit 1
$ git status
On branch master
nothing to commit (working directory clean)
$ git stash pop
Changes to be committed:
  new file:   j
Changed but not updated:
  modified:   b
  deleted:    c
  modified:   d

Создать новую ветку testchanges с началом из того коммита, на котором вы находились, когда переносили последние правки в тайник, переключиться на нее и удалить спрятанное из тайника, если оно применилось успешно.

$ git stash branch testchanges
Switched to a new branch "testchanges"
# On branch testchanges
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#      modified:   index.html
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#      modified:   lib/simplegit.rb
#
Dropped refs/stash@{0} (f0dfc4d5dc332d1cee34a634182e168c4efc3359)

Просматриваем и отчищаем то, что хранит git stash

$ git stash list
stash@{0}: WIP on new-menu: 0c26593 Fixed link at header
stash@{1}: WIP on master: 604670f ...
$ git stash clear
$ git stash list
-----------