git stash命令使用手册
修改记录压栈保存:
git stash push -u -m "msg" // -u ~ --意思是包含未被跟踪的文件
git stash push -m "msg"
git stash // 保存当前修改到stash@{0},stash缓存站的顶部
git stash save -u "msg"
git stash save -a "msg" // 包含所有文件,如.gitignore...
push 和 save 的区别:
save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]
This option is deprecated in favour of git stash push. It differs from "stash push" in that it cannot take pathspecs, and any non-option arguments form the message.
push [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [-m|--message <message>] [--] [<pathspec>…]
Save your local modifications to a new stash entry and roll them back to HEAD (in the working tree and in the index). The <message> part is optional and gives the description along with the stashed state.
For quickly making a snapshot, you can omit "push". In this mode, non-option arguments are not allowed to prevent a misspelled subcommand from making an unwanted stash entry. The two exceptions to this are stash -p which acts as alias for stash push -p and pathspecs, which are allowed after a double hyphen -- for disambiguation.
https://git-scm.com/docs/git-stash
git stash list // 查看stash列表
1、添加改动到stash
git stash save "messeag"
git stash save -m "messeag"
git stash save -u "messeag"
git stash save -a "messeag"
-a表示all,是不仅仅把新加入的代码文件放入暂存区,还会把用.gitignore忽略的文件放入暂存区。如果想不影响被忽略的文件,那就要用-u,表示untracked files。
2、恢复改动
git stash list查看stash列表,从中选择你想要pop的stash,运行命令
git stash pop stash@{id}
或者
git stash apply stash@{id} 即可
3、删除stash
git stash drop <stash@{id}> 如果不加stash编号,默认的就是删除最新的,也就是编号为0的那个,加编号就是删除指定编号的stash。
git stash clear 是清除所有stash
4、git stash pop 与 git stash apply <stash@{id}> 的区别。
git stash pop stash@{id}命令会在执行后将对应的stash id 从stash list里删除,而 git stash apply stash@{id} 命令则会继续保存stash id
5. 查看指定stash的diff
git stash show
git stash show stash@{id}
补充:
注:[]方括号中内容为可选,[<stash>]里面的stash代表进度的编号形如:stash@{0}, <>尖括号内的必填
git stash 对当前的暂存区和工作区状态进行保存。
git stash list 列出所有保存的进度列表。
git stash pop [--index] [<stash>] 恢复工作进度
git stash apply [--index] [<stash>] 不删除已恢复的进度,其他同git stash pop
git stash drop [<stash>] 删除某一个进度,默认删除最新进度
git stash clear 删除所有进度
git stash branch <branchname> <stash> 基于进度创建分支
refs:
https://git-scm.com/docs/git-stash
git stash命令总结
https://blog.csdn.net/c_z_w/article/details/52862129
progit
https://git-scm.com/book/zh/v2
SYNOPSIS
git stash list [<options>]
git stash show [<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>…]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>
相关文章
- Git创建分支和查看分支命令「建议收藏」
- 04·灵魂前端工程师养成-git远程仓库GitHub
- 常用git命令整理
- git 那些事儿 —— 基于 Learn Git Branching
- git仓库配置及仓库特性
- Git常用命令解析
- 测试开发必备的Linux,Redis和Git命令
- Git Submodules 介绍(通俗易懂,总结了工作完全够用的 submodule 命令)
- 关于使用 git 命令行时遇到的错误消息 unable to get local issuer certificate
- 每个 Tester 都应该知道的 Git 命令
- 【git】随手记
- git实用命令(二)
- git stash 命令详解(保存开发进度)
- git status 查看仓库文件状态
- git 命令别名配置
- Git工作流协作的一些经验,分支、合并、提交,推送,移除历史
- 使用PHPStorm自带的Git版本控制,出现Git.exe占用内存过高
- 【Git】IDEA使用Git(完)
- 【Git】Git 基础命令 ( 查看提交记录 git log | 版本回滚 git reset | 撤销回滚 git reflog )
- Git与Linux结合:创造无限可能(git和linux)
- Linux下的Git版本控制管理实战(linux的git)
- 学习Linux下的Git版本控制(linux上使用git)
- Linux内核管理:Git的力量(linux内核git)
- 环境配置Linux下的Git环境:一步一步(git配置linux)
- git和春天、Linux和Git一起收获成功(springlinux)
- 管理Linux分支掌控:利用Git进行版本管理(linux的分支)
- 安装Git服务器:在Linux环境下的步骤(linux安装git服务器)
- 开创自动化Redis集群Git部署(redis集群git)