git stash相关命令解释

git stash

这个命令会保存你当前工作区和暂存区的所有更改到一个临时的"stash"区域,然后使你的工作目录和暂存区变得干净(即回到最近一次提交的状态)。

当你想要回到这个"stash"区域中的更改时,你可以使用 git stash list 来查看所有 stash,然后使用 git stash pop 或 git stash apply 来恢复更改。
git stash drop

这个命令用于删除最近的 stash(或者,如果你提供了参数,那么会删除特定的 stash)。

默认情况下,它会删除最近的 stash。但如果你想要删除特定的 stash,你可以使用 git stash drop <stash_id>,其中 <stash_id> 是通过 git stash list 命令得到的 stash 的唯一标识符。
git stash list

这个命令会列出所有保存的 stash。每个 stash 都有一个唯一的标识符(通常是 stash@{0}、stash@{1} 等),以及一个描述性的消息(如果你在保存 stash 时提供了)。

使用这个列表,你可以知道你有哪些 stash 以及它们的大致内容,从而决定如何恢复或删除它们。

除了上述命令外,还有一些与 git stash 相关的其他命令也很有用:

git stash save "" :这类似于 git stash,但允许你为 stash 添加一个描述性的消息。这可以帮助你记住 stash 的内容或目的。
git stash pop :这个命令会从 stash 列表中删除最近的一个 stash,并将其内容应用到你当前的工作目录和暂存区。这实际上是 git stash apply 和 git stash drop 的组合。
git stash apply <stash_id>:这个命令会将特定的 stash 应用到你当前的工作目录和暂存区,但不会从 stash 列表中删除它。这允许你多次应用同一个 stash。

相关推荐
b1ng6 小时前
新人程序员 Git 一站式指南
git·github
程序员的世界你不懂7 小时前
IDE 关联 Git 操作
ide·git
weixin_428498498 小时前
Git Submodule 介绍和使用指南
git
jingshaoqi_ccc20 小时前
GitKraken最后一个免费版本和下载地址
git·github·gitkraken·版本管理工具
乌云暮年20 小时前
Git简单命令
git·gitee·github·batch命令
用户1259265423201 天前
使用 Docker 搭建 Gitea 并实现 Git HTTP 自动登录
git
一只毛驴1 天前
谈谈对git stash的理解?
git
长风破浪会有时呀1 天前
Git 学习笔记
笔记·git·学习
中微子2 天前
Git Rebase 详解:概念、原理与实战示例
git
荔枝吻2 天前
【保姆级喂饭教程】Windows下安装Git Flow
windows·git·git flow