IntelliJ 的 Shelve 和 Git stash 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32982204/
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
What is the difference between IntelliJ's Shelve and Git stash?
提问by Daniel Compton
IntelliJ supports git stashes as well as it's own built in shelve command. These seem to be almost identical in purpose and utility. What is the difference between them?
IntelliJ 支持 git stashes 以及它自己内置的 shelve 命令。这些在目的和效用上似乎几乎相同。它们之间有什么区别?
采纳答案by Daniel Compton
From the IntelliJ documentation:
从 IntelliJ文档:
In the Git integration, in addition to shelving and unshelving, "stashing" and "unstashing" are supported respectively. These features have much in common, the only difference is in the way patches are generated and applied.
- Patches with stashed changes are generated by Git itself. To apply them later, you do not need IntelliJ IDEA.
- Patches with shelved changes are generated by IntelliJ IDEA. Normally, they are also applied through the IDE. Applying shelved changes outside IntelliJ IDEA is also possible but requires additional steps.
在Git 集成中,除了shelving 和unshelving 之外,还分别支持“stashing”和“unstashing”。这些功能有很多共同点,唯一的区别在于补丁的生成和应用方式。
- 带有隐藏更改的补丁由 Git 本身生成。要稍后应用它们,您不需要 IntelliJ IDEA。
- 具有搁置更改的补丁由 IntelliJ IDEA 生成。通常,它们也通过 IDE 应用。在 IntelliJ IDEA 之外应用搁置的更改也是可能的,但需要额外的步骤。
回答by id.bobr
They are pretty similar except:
它们非常相似,除了:
- You can't use shelve outside IDE, because it is Intellij's feature.
- Git stash works only with entire working directory and index. IntelliJ's shelve can work with individual files and changelists (another IntelliJ's feature). As you can see, for example, here, sometimes it is necessary.
- Idea has better built-in support for shelve. Working with git stash is more straightforward. In particular, you can shelve\unshelve your changes or review shelved files from version control tool window.
- 您不能在 IDE 之外使用搁置,因为它是 Intellij 的功能。
- Git stash 仅适用于整个工作目录和索引。IntelliJ 的搁架可以处理单个文件和更改列表(IntelliJ 的另一个功能)。例如,如您所见,此处有时是必要的。
- Idea 对搁置有更好的内置支持。使用 git stash 更简单。特别是,您可以搁置\取消搁置您的更改或从版本控制工具窗口查看搁置的文件。
Also, IMHO, shelve works slightly faster, especially in a big project, when lots of files were changed.
此外,恕我直言,搁置的工作速度稍快,特别是在一个大项目中,当大量文件被更改时。
See the documentationfor more info.
有关更多信息,请参阅文档。
回答by riyasvaliya
One distinct advantage that Intellij's Shelve has over plain Git's stash is that using Shelve, you can save changes belonging to multiple repos in one changelist. Using stash, you would need to stash/unstash in each repo individually. This is very useful in a large project with multiple modules (each having its own repo) where a particular feature work may cut across multiple modules (and therefore multiple repos)
Intellij 的 Shelve 与普通 Git 存储相比的一个明显优势是,使用 Shelve,您可以将属于多个存储库的更改保存在一个更改列表中。使用 stash,您需要单独在每个 repo 中进行 stash/unstash。这在具有多个模块(每个模块都有自己的存储库)的大型项目中非常有用,其中特定功能工作可能会跨越多个模块(因此有多个存储库)
回答by Sagar
Here is what DocumentationSays
这里是什么文件说
Stashing changes is very similar to shelving. The only difference is in the way patches are generated and applied. Stashes are generated by Git, and can be applied from within IntelliJ IDEA, or outside it. Patches with shelved changes are generated by IntelliJ IDEA and are also applied through the IDE. Also, stashing involves all uncommitted changes, while when you put changes to a shelf, you can select some of the local changes instead of shelving them all.
存储更改与搁置非常相似。唯一的区别在于补丁的生成和应用方式。Stashes 由 Git 生成,可以在 IntelliJ IDEA 内部或外部应用。带有搁置更改的补丁由 IntelliJ IDEA 生成,也通过 IDE 应用。此外,存储涉及所有未提交的更改,而当您将更改放入架子时,您可以选择一些本地更改而不是将它们全部搁置。