您的位置:首页 > 其它

git stash操作

2015-12-24 18:34 513 查看
在git操作中,有时修改了code,然后要切换到其他的branch进行工作。这时,如果有部分code不需要提交commit,有不想丢弃,则可以进行stash操作。

下面是stash help提供的信息:

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 [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [<message>]]

git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>


在一般的工作中,需要的操作一般如下:

git stash save "message"
// ...... 其他操作

// 取回
git stash pop --index


比如:

>>>git stash save "config-change for localhost"
>>>git stash list
stash@{0}: On base_pay: config-change for localhost
stash@{1}: 1
stash@{2}: 1
stash@{3}: 1
stash@{4}: 1
stash@{5}: 111
>>>git stash pop --0
On branch master_new
>>>git stash clear
>>>git stash list
>>>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: