git 隐藏使用 atlassian sourcetree 所做的更改

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23898093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 18:08:01  来源:igfitidea点击:

Stash the changes made with atlassian sourcetree

gitatlassian-sourcetreegit-stash

提问by clankill3r

I have a lot of files changed in my project. I want to stash 2 files but i'm a bit afraid to make a mistake since i never did this.

我的项目中更改了很多文件。我想存储 2 个文件,但我有点害怕犯错,因为我从来没有这样做过。

If i would stash now, will it only stash the 2 staged files? enter image description here

如果我现在要藏起来,它会只藏 2 个暂存文件吗? 在此处输入图片说明

And if I don't mark the "Keep staged changes", will it then revert to how it was before? This might sound stupid, but better save then sorry.

如果我不标记“保持分阶段更改”,它会恢复到以前的状态吗?这听起来可能很愚蠢,但最好保存然后抱歉。

回答by

This applies to Git in general, not just with SourceTree. When you stash changes, the items that will be stashed are the changes to tracked filesin your working copy and in the staging area. Those changes will be saved in the stash, and reverted in the working copy and index.

这通常适用于 Git,而不仅仅是 SourceTree。当您存储更改时,将被存储的项目是对工作副本和暂存区域中跟踪文件的更改。这些更改将保存在 stash 中,并在工作副本和索引中恢复。

When you choose to keep changes in the index/staging area, those changes will still be stashed, but Git won't also revert them in the staging area.This is useful if, for example, you make several unrelated changes, and you want to run tests only some of those changes, without having the unrelated ones affect the test.

当您选择在索引/暂存区中保留更改时,这些更改仍将被隐藏,但 Git 也不会在暂存区中恢复它们。例如,如果您进行了几个不相关的更改,并且您只想运行其中的一些更改而不让不相关的更改影响测试,这将非常有用。

Stashing is safe. If you want to get your stashed changes back, you just pop them back out of the stash.

藏匿是安全的。如果您想取回隐藏的更改,只需将它们从存储中弹出即可。

However, untracked filesaren't normally stashed. If you want to also stash those files, you need to pass an additional option to git stashon the command line (SourceTree for Windows doesn't currently have such an option. I don't know if the same is true for the Mac version):

但是,通常不会隐藏未跟踪的文件。如果你还想隐藏这些文件,你需要git stash在命令行上传递一个额外的选项(Windows的SourceTree目前没有这样的选项。我不知道Mac版本是否也是如此):

git stash save --include-untracked
# Or shorter
git stash save -u

See Also

也可以看看

回答by gravetii

Yes, but stashing in this case would mean two scenarios -

是的,但在这种情况下藏匿意味着两种情况——

  1. Checking the Keep staged changes: staged files would still be in your staging area, but all your modified unsaved files will be stashed.

  2. Without checking the staged changes: all your files will be stashed.

  1. 检查保留暂存更改:暂存文件仍将在您的暂存区域中,但所有修改后的未保存文件将被隐藏。

  2. 不检查分阶段更改:您的所有文件都将被隐藏。