为什么'git stash apply'会改变我的改变? [英] Why does 'git stash apply' stage my changes?

查看:151
本文介绍了为什么'git stash apply'会改变我的改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个修改,然后我 git stash ,然后我 git stash apply



我的问题是


  1. 为什么在我 git stash apply ,我的变化会变成'上演'?即我不会看到任何东西,如果我做 git diff ,我只看到我的区别,如果我做 git diff --cached

  2. 有没有办法让我的更改由 git stash apply 命令执行?

  3. 是否有任何git命令基本上允许我对我的更改进行备份,将其重置为HEAD并将备份复制回来?我认为 git stash ,然后 git stash apply 是该命令,但是有些如何将所有更改分阶段进行?是否有任何等价物让我 git stash apply 没有我的变更部分?


谢谢。

解决方案

如果您发现您的更改意外暂存,请执行以下操作:

  git reset HEAD 

如果在应用隐藏的更改时发生冲突,我通常只会看到这一点。您需要在执行 git reset 之前检查是否出现这种情况。



git stash 命令是您的用例最合适的命令。我一直用它来达到这个目的。


I make a change and then I git stash and then I git stash apply

My question is

  1. why after I git stash apply, my change becomes 'staged'? i.e. I won't see anything if I do git diff, I only see my difference if I do git diff --cached?

  2. Is there anyway to 'unstage' my changes staged by git stash apply command?

  3. Is there any git command basically let me to 'make a backup of my change, reset it to the HEAD and the copy my backup back'? I thought git stash and then git stash apply is that command, but some how it 'staged' all my changes? Is there any equivalent which let me git stash apply without the staged my changes part?

Thank you.

解决方案

If you find that your changes are unexpectedly staged, do:

git reset HEAD

I usually only see this if there is a conflict when applying the stashed changes. You will want to check to see whether this is the case before doing the git reset.

The git stash command is the most appropriate command for your use case. I use it all the time for exactly this purpose.

这篇关于为什么'git stash apply'会改变我的改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆