设为首页 收藏本站
查看: 3258|回复: 0

[经验分享] git stash的使用

[复制链接]
发表于 2018-1-15 18:28:22 | 显示全部楼层 |阅读模式
  The latest stash you created is stored in refs/stash; older stashes are found in the reflog of this reference and can be named using the usual reflog syntax (e.g. stash@{0} is the most recently created stash, stash@{1} is the one before it,stash@{2.hours.ago} is also possible).
git stash list
  查看之前缓存的所有stash
  $ git stash list
  stash@{0}: WIP on temp: 36b0f5f 删除HSDataFrameManager类中多余的代码      //第二次的stash,覆盖了第一次【git stash apply的时候,只能出现这一次的,上一次的不会出现】
  stash@{1}: WIP on temp: 36b0f5f 删除HSDataFrameManager类中多余的代码      //第一次的stash
  stash@{2}: WIP on temp: c723e17 接收到消息的时候,打印出消息类型,如果消息内部有
  stash@{3}: WIP on temp: 18fa2a3 连接通讯模块时,需要将主窗体的窗口句柄传递给通讯
  temp是分支的名字
  第0个和第1个虽然看起来完全一样,但实际上是不同的
git stash list --date=local
  $ git stash list --date=local
  stash@{Fri Dec 15 15:20:55 2017}: On local: event log
  stash@{Tue Dec 12 18:12:25 2017}: On local: chile configuration
  stash@{Thu Nov 30 13:50:49 2017}: On local: RDCLIS-191
git stash show
  查看list中的某一次stash
  $ git stash show stash@{0}
  ZBMYun/SourceCode/ZITakerHS/ZITaker/SystemConfig.ini | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
  $ git stash show stash@{1}
  ZBMYun/SourceCode/ZITakerHS/ZITaker/UI/Main.cs               | 2 +-
  ZBMYun/SourceCode/ZITakerHS/ZITaker/ZbmStorage_Component.ini | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
  git stash show stash@{0} -u
  添加-u参数可以输出某一次stash的所有文件差异对比
git stash apply
  可以apply指定的stash,如果你不指定的话,默认apply最近一次的stash
  If you want to apply one of the older stashes, you can specify it by naming it, like this: git stash apply stash@{2}.
  If you don’t specify a stash, Git assumes the most recent stash and tries to apply it:
git stash drop
  $ git stash list
  stash@{0}: WIP on local: 63b9f1b DebugInfoManager类,在FormMain加载的时候需要主
  stash@{1}: WIP on svn: 78ab728 设备第一次上线后,直接发送采集数据,在这种情况下
  $ git stash drop stash@{0}
  Dropped stash@{0} (1136bc142780259d8541c7e3a605ff2250cc9427)

git stash pop
  pop [--index] [-q|--quiet] [<stash>]
  Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash save. The working directory must match the index.
  Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.
  If the --index option is used, then tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).
  When no <stash> is given, stash@{0} is assumed, otherwise <stash> must be a reference of the form stash@{<revision>}.
git stash save
  这样的log更具有可读性
  Options:
  save [-p|--patch] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]
  Save your local modifications to a new stash, and run git reset --hard to revert them.
  The <message> part is optional and gives the description along with the stashed state.
  For quickly making a snapshot, you can omit both "save" and <message>, but giving only <message> does not trigger this action to prevent a misspelled subcommand from making an unwanted stash.
  If the --keep-index option is used, all changes already added to the index are left intact.
  If the --include-untracked option is used, all untracked files are also stashed and then cleaned up with git clean, leaving the working directory in a very clean state.
  If the --all option is used instead then the ignored files are stashed and cleaned in addition to the untracked files.
在TortoiseGit中查看
  假如stash的节点,是在一个月前的某个commit上进行stash。那么查看日志,建议按照时间排序,先定位到stash,通过分支线去找到父节点。
  正常情况下,日志还是需要按照topo-order来排序

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-435420-1-1.html 上篇帖子: Git基本命令行操作 下篇帖子: china_blue
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表