文档章节

git stash

Oscarfff
 Oscarfff
发布于 2016/07/20 11:02
字数 390
阅读 5
收藏 0

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

 参考博文:https://git-scm.com/docs/git-stash

 

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 [<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>

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://git-scm.com/docs/git-stash

共有 人打赏支持
上一篇: git tag
Oscarfff
粉丝 74
博文 816
码字总数 97116
作品 0
崇明
后端工程师
私信 提问

暂无文章

JDK1.8新特性

1.Java 8 允许我们给接口添加一个非抽象的方法实现,只需要使用default关键字即可,这个特征又叫扩展方法。 2.Lambda 表达式。参数 => 主体。Lambda表达返回右边表达式的结果。 3.用 :: 关键...

无精疯
21分钟前
1
0
http_load压测服务器

1.下载http_load ,下载地址:http://acme.com/software/http_load/http_load-12mar2006.tar.gz [root@localhost ~]#cd /usr/local[root@localhost local]#mkdir http_load[root@loc......

win_ball
22分钟前
0
0
Spark集群安装方式2

环境: jdk1.8、hadoop-2.7、spark-1.6、三台centos7(如下List-1所示) List-1 如下30上部署master;31上部署worker1;32上部署worker2 192.168.33.30 master192.168.33.31 worker1192.168.......

克虏伯
37分钟前
2
0
java File常用的方法

import java.io.File; public class a_22 { public static void main(String[] args) {File f= new File("D:\\tianya\\2019.3.14\\html");System.out.println(f.isDirectory());Syste......

南桥北木
45分钟前
2
0
Go基础系列:双层channel用法示例

双层通道的解释见Go的双层通道 以下是一个双层通道的使用示例。注意下面的示例中使用了"信号通道"(Signal channel),但这里的信号通道是多余的,仅仅只是为了介绍。 信号通道不用来传递数据,...

echojson
今天
2
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部