博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git stash
阅读量:6446 次
发布时间:2019-06-23

本文共 2326 字,大约阅读时间需要 7 分钟。

hot3.png

1.Pulling into a dirty tree

When you are in the middle of something, you learn that there are upstream changes that are possibly relevant to what you are doing. When your local changes do not conflict with the changes in the upstream, a simple git pull will let you move forward.

However, there are cases in which your local changes do conflict with the upstream changes, and git pull refuses to overwrite your changes. In such a case, you can stash your changes away, perform a pull, and then unstash, like this:

$ git pull ...file foobar not up to date, cannot merge.$ git stash$ git pull$ git stash pop

 参考博文:

 

2.Interrupted workflow

When you are in the middle of something, your boss comes in and demands that you fix something immediately. Traditionally, you would make a commit to a temporary branch to store your changes away, and return to your original branch to make the emergency fix, like this:

# ... hack hack hack ...$ git checkout -b my_wip$ git commit -a -m "WIP"$ git checkout master$ edit emergency fix$ git commit -a -m "Fix in a hurry"$ git checkout my_wip$ git reset --soft HEAD^# ... continue hacking ...

You can use git stash to simplify the above, like this:

# ... hack hack hack ...$ git stash$ edit emergency fix$ git commit -a -m "Fix in a hurry"$ git stash pop# ... continue hacking ...

 

SYNOPSIS

git stash list [
]git stash show [
]git stash drop [-q|--quiet] [
]git stash ( pop | apply ) [--index] [-q|--quiet] [
]git stash branch
[
]git stash [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [
]]git stash cleargit stash create [
]git stash store [-m|--message
] [-q|--quiet]

drop [-q|--quiet] [<stash>]

Remove a single stashed state from the stash list. When no <stash> is given, it removes the latest one. i.e. stash@{0}, otherwise <stash> must be a valid stash log reference of the formstash@{<revision>}.

list [<options>]

List the stashes that you currently have. Each stash is listed with its name (e.g. stash@{0} is the latest stash, stash@{1} is the one before, etc.), the name of the branch that was current when the stash was made, and a short description of the commit the stash was based on.

转载于:https://my.oschina.net/u/2308739/blog/714896

你可能感兴趣的文章
Delphi MaskEdit用法
查看>>
五款免费的Windows 8 Metro风格主题
查看>>
android:menu.xml
查看>>
RecyclerView 知识梳理(5) ItemTouchHelper
查看>>
干货分享:智慧工厂时代下大数据 + 智能的深度实践
查看>>
新功能:阿里云负载均衡SLB支持HTTP/HTTPS超时时间自定义功能
查看>>
跟着Zepto学dom(二)
查看>>
面试Tip:Android优化之APK瘦身
查看>>
大咖推荐!今年值得一读的6本技术类书籍
查看>>
websocket 之入门
查看>>
JDK1.8源码(三)——java.util.HashMap
查看>>
Android双列表联动和固定头部ScrollView效果实现
查看>>
Flink Window分析及Watermark解决乱序数据机制深入剖析-Flink牛刀小试
查看>>
前端开发中的代码艺术(精要)
查看>>
代理模式相关使用
查看>>
JavaScript标签内属性和数组
查看>>
leetCode刷题 23. 合并K个排序链表
查看>>
关于CSS中position的定位技术
查看>>
iOS加载gif动画
查看>>
es6 for-of 和 胖箭头的简单用法
查看>>