修改記錄壓棧保存:
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>