1、stash
Storage. After saving the state of progress of the current work area and staging area, fall back on a git commit
2, the principle
Modifications and changes to the staging of the trace file, and then save unfinished modifications to a stack, and you can re-apply these changes at any time.
3, commonly used commands
(1 ) Create a cache
Format: git stash [push [-p | --patch] [-k | - [no-] keep-index] [-q | --quiet]
[-u|--include-untracked] [-a|--all] [-m|--message <message>]
[--] [<pathspec>…]]
stash git => Create a Cache
stash the Save git " the Message " => Create a store, and add comments. Save all changes
message, optional, add notes during storage.
stash the Push -m git " the Message " => create cache, and add comments. Save all changes
Push {stash Git path } => the file cache location specified
path, the path you want to save the file cache
(2) View cache list
Format: git stash list [<options>]
List stash git => View all cache list
(3) the restoration buffer
格式:git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
POP stash git => recover the first cache, and delete the cache from the cache list
POP stash stash @ {Git index } => recovery specified cache, delete the cache from the cache list and
index, cache index
Apply stash Git => Application of a cache, and cache retention
Apply stash stash @ {Git index } => the application specifies the cache and the cache retention
index, cache index
(4) change the display buffer
格式:git stash show [<options>] [<stash>]
Show stash Git -p => Show a buffer change
Show stash Git stash @ { index } -p => Showing page index buffer changes
index, cache index
-p / - patch, optional, see specific cache changes
(5) Delete Cache
Format: git stash clear
the Clear stash git => Delete entire cache
Clear @ {stash stash Git index } => to delete the specified cache
index, to delete the cache index
(6) to remove the cache
Format: git stash drop [-q | --quiet] [<stash>]
stash drop git => remove the cache, the first default
@ {stash stash drop Git index } => removes the first cache index
index, to be removed cached subscript
(7) creating a branch
格式:git stash branch <branchname> [<stash>]
Create a new branch according to the most recent stash, and then delete the most recent stash
Branch stash git < BRANCHNAME > => Create a new branch according to the latest stash, and then delete the latest stash
Branch stash Git < BRANCHNAME > stash { index } => Create a new branch according stash specified, and then delete the specified stash
branchname, the new branch name
index, stash subscript
(8) to create a floating submitted
格式:git stash create [<message>]
git stash create "message" => 创建一个悬空提交 (dangling commit),不会将 ref 存储在任何地方
(9)存储上一个命令中创建的悬空提交
格式:git stash store [-m|--message <message>] [-q|--quiet] <commit>
参数
-q|--quiet
静默模式-p|--patch
以 patch 方式 push stash-k|--[no-]keep-index
保留 index 序号-u|--include-untracked
untracked 状态的文件也会被 push-a|--all
untracked 和 ignored 的文件也会被 push-m|--message
<message>
输出 stash 信息-- [<pathspec>]
针对特定的路径 push
参考链接
官网:https://git-scm.com/docs/git-stash
https://git-scm.com/book/zh/v2/Git-%E5%B7%A5%E5%85%B7-%E5%82%A8%E8%97%8F%E4%B8%8E%E6%B8%85%E7%90%86
https://www.yiibai.com/git/git_stash.html
https://segmentfault.com/a/1190000019283898
https://www.cnblogs.com/zndxall/archive/2018/09/04/9586088.html