Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git Stash 用法

git stash用于保存和恢复工作进度

  • git stash

    保存当前的工作进度。会分别对暂存区和工作区的状态进行保存

  • git stash save "message..."

    这条命令实际上是第一条 git stash 命令的完整版

  • git stash list

    显示进度列表。此命令显然暗示了git stash 可以多次保存工作进度,并用在恢复时候进行选择

  • git stash pop [--index] [<stash>]

    如果不使用任何参数,会恢复最新保存的工作进度,并将恢复的工作进度从存储的工作进度列表中清除。

    如果提供参数(来自 git stash list 显示的列表),则从该 <stash> 中恢复。恢复完毕也将从进度列表中删除 <stash>

    选项--index 除了恢复工作区的文件外,还尝试恢复暂存区。

  • git stash apply [--index] [<stash>]

    除了不删除恢复的进度之外,其余和 git stash pop 命令一样

  • git stash clear

    删除所有存储的进度

@CHENGP618

This comment has been minimized.

Show comment
Hide comment
@CHENGP618

CHENGP618 Jul 13, 2016

我用的fish shell,git stash pop stash@{1} 不认,必须要加反转符git stash pop stash@{1},各位好运

我用的fish shell,git stash pop stash@{1} 不认,必须要加反转符git stash pop stash@{1},各位好运

@doublnt

This comment has been minimized.

Show comment
Hide comment
@doublnt

doublnt Feb 16, 2017

Thank you . That's help me a lot.

doublnt commented Feb 16, 2017

Thank you . That's help me a lot.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 23, 2017

赞。。

ghost commented Feb 23, 2017

赞。。

@0xtonyxia

This comment has been minimized.

Show comment
Hide comment
@0xtonyxia

0xtonyxia Jul 3, 2017

Thanks. Very helpful.

Thanks. Very helpful.

@Adaxyl

This comment has been minimized.

Show comment
Hide comment
@Adaxyl

Adaxyl Jul 13, 2017

thanks very much

Adaxyl commented Jul 13, 2017

thanks very much

@holdqv

This comment has been minimized.

Show comment
Hide comment
@holdqv

holdqv Sep 29, 2017

能否把其他分支的stash直接拉到当分支呢?

holdqv commented Sep 29, 2017

能否把其他分支的stash直接拉到当分支呢?

@Tbwas

This comment has been minimized.

Show comment
Hide comment
@Tbwas

Tbwas Oct 18, 2017

简单明了,通俗易懂

Tbwas commented Oct 18, 2017

简单明了,通俗易懂

@liweigong

This comment has been minimized.

Show comment
Hide comment
@liweigong

liweigong Jan 5, 2018

简单明白

简单明白

@xmgtih

This comment has been minimized.

Show comment
Hide comment
@xmgtih

xmgtih Jan 18, 2018

简单明了,赞

xmgtih commented Jan 18, 2018

简单明了,赞

@1024zhangli

This comment has been minimized.

Show comment
Hide comment

Good

@zhoutao825638

This comment has been minimized.

Show comment
Hide comment

Nice,Thanks!

@dickxdeng

This comment has been minimized.

Show comment
Hide comment
@dickxdeng

dickxdeng Jun 14, 2018

没有例子,还是不够明了

没有例子,还是不够明了

@courage007

This comment has been minimized.

Show comment
Hide comment
@courage007

courage007 Jun 23, 2018

Greate! It is worked when i used git stash save xxxgit stash pop and git stash clear

courage007 commented Jun 23, 2018

Greate! It is worked when i used git stash save xxxgit stash pop and git stash clear

@Qoozm

This comment has been minimized.

Show comment
Hide comment

Qoozm commented Jul 27, 2018

good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment