简体中文 ▾
Localized versions of git-stash manual
Topics ▾
Email
Latest version
▾
git-stash last updated in 2.55.0
Changes in the git-stash manual
Setup and Config
Getting and Creating Projects
Basic Snapshotting
Branching and Merging
Sharing and Updating Projects
Inspection and Comparison
Patching
Debugging
External Systems
Server Admin
Guides
- gitattributes
- Command-line interface conventions
- Everyday Git
- Frequently Asked Questions (FAQ)
- Glossary
- Hooks
- gitignore
- gitmodules
- Revisions
- Submodules
- Tutorial
- Workflows
- All guides...
Administration
Plumbing Commands
-
2.55.0
2026-06-29
-
2.54.0
2026-04-20
- 2.53.0 no changes
-
2.52.0
2025-11-17
- 2.51.1 → 2.51.2 no changes
-
2.51.0
2025-08-18
- 2.43.1 → 2.50.1 no changes
-
2.43.0
2023-11-20
- 2.42.1 → 2.42.4 no changes
-
2.42.0
2023-08-21
- 2.39.1 → 2.41.3 no changes
-
2.39.0
2022-12-12
- 2.38.1 → 2.38.5 no changes
-
2.38.0
2022-10-02
- 2.35.1 → 2.37.7 no changes
-
2.35.0
2022-01-24
- 2.32.1 → 2.34.8 no changes
-
2.32.0
2021-06-06
- 2.31.1 → 2.31.8 no changes
-
2.31.0
2021-03-15
- 2.26.1 → 2.30.9 no changes
-
2.26.0
2020-03-22
- 2.24.1 → 2.25.5 no changes
-
2.24.0
2019-11-04
- 2.23.1 → 2.23.4 no changes
-
2.23.0
2019-08-16
- 2.22.1 → 2.22.5 no changes
-
2.22.0
2019-06-07
- 2.17.1 → 2.21.4 no changes
-
2.17.0
2018-04-02
-
2.16.6
2019-12-06
- 2.15.4 no changes
-
2.14.6
2019-12-06
-
2.13.7
2018-05-22
-
2.12.5
2017-09-22
-
2.11.4
2017-09-22
- 2.8.6 → 2.10.5 no changes
-
2.7.6
2017-07-30
- 2.1.4 → 2.6.7 no changes
-
2.0.5
2014-12-17
概述
gitstashlist[<log-options>]gitstashshow[-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]gitstashdrop[-q|--quiet] [<stash>]gitstashpop[--index] [-q|--quiet] [<stash>]gitstashapply[--index] [-q|--quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [<stash>]gitstashbranch<branchname> [<stash>]gitstash[push] [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [(-m|--message) <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>…]gitstashsave[-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [<message>]gitstashcleargitstashcreate[<message>]gitstashstore[(-m|--message) <message>] [-q|--quiet] <commit>gitstashexport(--to-ref<ref>) [<stash>…]gitstashimport<commit>
描述
当你想记录工作区和索引的当前状态,但又想回到一个干净的工作区时,请使用 git stash。 该命令将你的本地修改保存起来,并将工作区还原为与 HEAD 提交相匹配。
这个命令所存储的修改可以用 git stash list 列出,用 git stash show 检查,用 git stash apply 恢复(可能是在不同的提交之上)。 在没有任何参数的情况下调用 git stash 等同于 git stash push。 默认情况下,贮藏库被列为 "WIP on branchname …",但你可以在创建贮藏库时在命令行中给出更多描述性信息。
你最近创建的贮藏库被保存在 refs/stash 中;旧的贮藏库可以在这个引用的引用日志中找到,并且可以使用通常的引用日志语法来命名(例如,stash@{0} 是最近创建的贮藏库,stash@{1} 是它之前的贮藏库,stash@{2.hours.ago} 也是可以的)。也可以通过指定贮藏库的索引来引用贮藏库(例如,整数 n 等同于 stash@{n})。