隐藏使用 atlassian sourcetree 所做的更改 [英] Stash the changes made with atlassian sourcetree

查看:28
本文介绍了隐藏使用 atlassian sourcetree 所做的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

如果我不标记保持分阶段更改",它会恢复到以前的状态吗?这听起来可能很愚蠢,但最好还是省去抱歉.

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.

推荐答案

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

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 files in 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 也不会在暂存区中恢复它们.这很有用,例如,您进行了几个不相关的更改,并且您只想运行其中一些更改的测试,而不会使不相关的更改影响测试.

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.

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

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

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

However, untracked files aren't normally stashed. If you want to also stash those files, you need to pass an additional option to git stash on 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 save --include-untracked
# Or shorter
git stash save -u

另见

  • git stash 的官方 Linux 内核文档.
  • See Also

    • The official Linux Kernel documentation for git stash.
    • 这篇关于隐藏使用 atlassian sourcetree 所做的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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