修改记录压栈保存:

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. c++11 强类型枚举

    c++11 强类型枚举 #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #inclu ...

  2. What is SCons?

    SCons: A software construction tool What is SCons? SCons is an Open Source software construction too ...

  3. 洛谷 P1654 OSU! 解题报告

    P1654 OSU! 题目描述 osu 是一款群众喜闻乐见的休闲软件. 我们可以把osu的规则简化与改编成以下的样子: 一共有\(n\)次操作,每次操作只有成功与失败之分,成功对应\(1\),失败对应 ...

  4. 网络传输---HttpURLConnection

    HttpURLConnection是java做网络传输的一种,一般用于做数据的传输如xml数据传输 1.创建及配置: 1.1创建一个url对象,并指定url的地址 URL url = new URL( ...

  5. android 系统开发板挂载U盘

    cat /proc/partitions 查看有u盘设备 df 查看挂载情况 iTOP4416开发板插入u盘,自动挂载到 /mnt/udisk1

  6. JVM调优命令-jps

    JVM Process Status Tool,显示指定系统内所有的HotSpot虚拟机进程. 命令格式 1 jps [options] [hostid] options参数-l : 输出主类全名或j ...

  7. 【DS】排序算法之插入排序(Insertion Sort)

    一.算法思想 一般来说,插入排序都采用in-place在数组上实现.具体算法描述如下:1)从第一个元素开始,该元素可以认为已经被排序2)取出下一个元素,在已经排序的元素序列中从后向前扫描3)如果该元素 ...

  8. Splay模板讲解及一些题目

    普通平衡树模板以及文艺平衡树模板链接. 简介 平衡二叉树(Balanced Binary Tree)具有以下性质:它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二 ...

  9. Java Message Service学习(一)

    一,背景 近期需要用到ActiveMQ接收Oozie执行作业之后的返回结果.Oozie作为消息的生产者,将消息发送给ActiveMQ,然后Client可以异步去ActiveMQ取消息. ActiveM ...

  10. 20155321 2016-2017-2 《Java程序设计》第五周学习总结

    20155321 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 第八章 异常处理 Java提供特有的语句进行处理 try { 需要被检测的代码; } cat ...