码迷,mamicode.com
首页 > 其他好文 > 详细

git stash简介

时间:2016-10-22 12:02:24      阅读:273      评论:0      收藏:0      [点我收藏+]

标签:html   comm   bsp   查看   off   代码   执行   follow   针对   

原文:http://gitbook.liuhui998.com/4_5.html

一、基本操作
当你正在做一项复杂的工作时, 发现了一个和当前工作不相关但是又很讨厌的bug. 你这时想先修复bug再做手头的工作, 那么就可以用 git stash 来保存当前的工作状态, 等你修复完bug后,执行‘反储藏‘(unstash)操作就可以回到之前的工作里.
$ git stash save "work in progress for foo feature"
上面这条命令会保存你的本地修改到储藏(stash)中, 然后将你的工作目录和索引里的内容全部重置, 回到你当前所在分支的上次提交时的状态.
好了, 你现在就可以开始你的修复工作了.
... edit and test ...
$ git commit -a -m "blorpl: typofix"
当你修复完bug后, 你可以用git stash apply来回复到以前的工作状态.  ??修改bug的代码,会提交,会在apply 之后保持在本地代码中?
$ git stash apply
二、储藏队列
你也可多次使用‘git stash‘命令, 每执行一次就会把针对当前修改的‘储藏’(stash)添加到储藏队列中. 
用‘git stash list‘命令可以查看你保存的‘储藏‘(stashes):
$>git stash list
stash@{0}: WIP on book: 51bea1d... fixed images
stash@{1}: WIP on master: 9705ae6... changed the browse code to the official repo
可以用类似‘git stash apply stash@{1}‘的命令来使用在队列中的任意一个‘储藏‘(stashes).
 ‘git stash clear‘则是用来清空这个队列.

git stash简介

标签:html   comm   bsp   查看   off   代码   执行   follow   针对   

原文地址:http://www.cnblogs.com/xingzc/p/5987018.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!