修改记录压栈保存:

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 stash命令使用手册的更多相关文章

  1. git stash命令详解

    git stash命令用于将更改储藏在脏工作目录中. 使用语法 git stash list [<options>] git stash show [<stash>] git ...

  2. 使用git stash命令保存和恢复进度

    使用git stash命令保存和恢复进度 git stash 保存当前工作进度,会把暂存区和工作区的改动保存起来.执行完这个命令后,在运行git status命令,就会发现当前是一个干净的工作区,没有 ...

  3. git stash 命令

    摘自: http://blog.csdn.net/longxiaowu/article/details/26815433 关于git stash命令的使用方法网上一大把,我想记录的是我在使用过程中觉得 ...

  4. git stash命令及提交指定文件

    一.git stash命令 常用git stash命令: (1)git stash save "save message" : 执行存储时,添加备注,方便查找,只有git stas ...

  5. git 命令参考手册 git中文命令参考手册大全

    git init # 初始化本地git仓库(创建新仓库)git config --global user.name "xxx" # 配置用户名git config --global ...

  6. git stash命令

    命令:git stash 1.使用git stash 保存当前的工作现场, 那么就可以切换到其他分支进行工作,或者在当前分支上完成其他紧急的工作,比如修订一个bug测试提交. 2.如果一个使用了一个g ...

  7. Git常用命令参考手册

    配置 # 查看全局配置列表 git config -l # 查看局部配置列表 git config --local --list # 查看已设置的全局用户名/邮箱 git config --globa ...

  8. 每天一命令 git stash

    git stash  命令是用于保存当前进度的命令.该命令会保存当前工作区的改动.保存的改动是已经跟踪的文件的改动,对于未跟踪的改动stash是不会保存的. git stash 命令常用于分支切换的 ...

  9. 关于Git的stash命令

    add 添加新文件到 Git 代码仓库的索引中 $ git add filename mv 移动或重命名文件 $ git mv old-filename new-filename rm 从工作目录和 ...

随机推荐

  1. Before NOIP2017

    明天就比赛了呢! 说起来,这是我第二次,可能也是最后一次正式参加提高组的比赛了. 虽然是从初中就有参加信息学的学习,但是认真学习信息竞赛还是去年七月开始的.NOIP2016 中,我凭着两天的简单题和一 ...

  2. 【题解】 [POI2012]FES-Festival (差分约束)

    懒得复制题面,戳我戳我 Question: (因为网上找不到好的翻译,这里简单复述一下) 告诉你\(m1+m2\)个约束条件,然后要你找出\(X_1-X_n\)这些数字,求满足要求的数列中不同的数字个 ...

  3. 【BZOJ4477】[JSOI2015]字符串树(Trie树)

    [BZOJ4477][JSOI2015]字符串树(Trie树) 题面 BZOJ 题解 对于每个点维护其到根节点的所有字符串构成的\(Trie\),显然可持久化一下就很好写了. 然后每次询问就是\(u+ ...

  4. GDOI2018 Day1 题目总结

    T1:农场 题意:有一个长为 $n$ 的序列 $a$,要求将其分成尽可能多的部分,使得每一部分的 $a_i$ 的和相等.求最多能分成的部分数. $30\%:1\le n\le 1000$ $80\%: ...

  5. 解题:HAOI 2015 按位或

    题面 Min-Max容斥:对于集合S $min(S)=\sum_{s∈S}(-1)^{|s|+1}max(s)$ $max(S)=\sum_{s∈S}(-1)^{|s|+1}min(s)$ 那么这个题 ...

  6. 【洛谷P3916】图的遍历

    题目大意:给定一个 N 个点,M 条边的有向图,求每个点能够到达的节点的最大编号是多少. 题解:因为题中所给图不一定是一个 DAG,因此无法进行按照拓扑序来动态规划,需要另辟蹊径.由于求的是每个节点能 ...

  7. ubuntu ssh root登陆

    原文:https://blog.csdn.net/wy_97/article/details/78294562 1.默认使用ubuntu用户登录,密码为服务器配置时设置的密码,可在重置密码中修改 2. ...

  8. Java基础-进制转换

    Java基础-进制转换 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Java 程序中常用的进制 1>.十进制,由“0123456789” 这10个数字组成,逢十进一: ...

  9. sublime代码对齐

    来源于:Sublime 自动缩进怎么设置? - 郭缔的回答 - 知乎 https://www.zhihu.com/question/22987174/answer/90874465 { "k ...

  10. 解决PHP curl https时error 77(Problem with reading the SSL CA cert (path? access rights?))

    服务器环境为CentOS,php-fpm,使用curl一个https站时失败,打开curl_error,捕获错误:Problem with reading the SSL CA cert (path? ...