git shanchu stash_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] []

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 ] [--] […​]

Save your local modifications to a new stash entry and roll them back to HEAD (in the working tree and in the index). The 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编号,默认的就是删除最新的,也就是编号为0的那个,加编号就是删除指定编号的stash。

git stash clear 是清除所有stash

4、git stash pop 与 git stash apply 的区别。

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@{0}, <>尖括号内的必填

git stash 对当前的暂存区和工作区状态进行保存。

git stash list 列出所有保存的进度列表。

git stash pop [--index] [] 恢复工作进度

git stash apply [--index] [] 不删除已恢复的进度,其他同git stash pop

git stash drop [] 删除某一个进度,默认删除最新进度

git stash clear 删除所有进度

git stash branch 基于进度创建分支

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 []

git stash show []

git stash drop [-q|--quiet] []

git stash ( pop | apply ) [--index] [-q|--quiet] []

git stash branch []

git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]

[-u|--include-untracked] [-a|--all] [-m|--message ]

[--] […​]]

git stash clear

git stash create []

git stash store [-m|--message ] [-q|--quiet]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值