🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[TOC] ## 概述 如果保存对文件的更改,并回复工作目录到 HEAD,可以使用更改 ## 语法 ``` git stash list [<options>] git stash show [<options>] [<stash>] git stash drop [-q|--quiet] [<stash>] git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>] git stash branch <branchname> [<stash>] git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [-m|--message <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>…​]] git stash clear git stash create [<message>] git stash store [-m|--message <message>] [-q|--quiet] <commit> ``` ## 场景 ### 提交搁置 ``` > git stash [-m "提交搁置"] ``` 不使用 -m 则commit 会使用最近一次 ### 列出搁置 ``` > 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 show [index] ``` - index 默认为 0 显示,显示最近一条搁置 ### 应用搁置 ``` > git stash [pop|apply] [index] ``` - index 默认为 0 ,应用最近一次的搁置 - pop 删除并应用搁置 - apply 只应用搁置,并不删除 ### 删除搁置 ``` > git stash drop [index] ``` - index 默认为 0 ,应用最近一次的搁置 ### 清空搁置 ``` > git stash clear ```