索引,缓存和在git中上演有什么区别? [英] What's the difference between the index, cached, and staged in git?
问题描述
这些都是一样的吗?如果是这样,为什么有这么多的条款?!
另外,我知道有这种叫做git stash的东西,这是一个地方,你可以暂时存储你的变化工作副本,而不会将其提交给回购。我发现这个工具非常有用,但是再一次,这个名字和git中的其他一些概念非常相似 - >这非常令人困惑!!
git的 stash
工具是一种方式将存储在特定存储目录/数据库中的提交对象存储在您目前不想提交的'正在进行中'的工作中)。基本的 stash
命令将存储对工作目录(缓存/暂存和未缓存/非暂存更改)的未提交更改,然后将工作目录恢复为HEAD。
它与索引/阶段/缓存没有什么关系,只不过它会将未提交的更改存储在缓存中。
这可以让您快速保存脏工作目录和索引的状态,以便您可以在干净的环境中执行不同的工作。稍后,您可以取回隐藏对象中的信息并将其应用于您的工作目录(即使工作目录本身处于不同的状态)。
官方 git存储
手册页具有相当不错的细节,但仍然可以理解。它也有很好的例子说明如何使用 stash
。
Are these the same thing? If so, why are there so many terms?!
Also, I know there is this thing called git stash, which is a place where you can temporarily store changes to your working copy without committing them to the repo. I find this tool really useful, but again, the name is very similar to a bunch of other concepts in git -> this is very confusing!!
The index/stage/cache are the same thing - as for why so many terms, I think that index was the 'original' term, but people found it confusing, so the other terms were introduced. And I agree that it makes things a bit confusing sometimes at first.
The stash
facility of git is a way to store 'in-progress' work that you don't want to commit right now in a commit object that gets stored in a particular stash directory/database). The basic stash
command will store uncommitted changes made to the working directory (both cached/staged and uncached/unstaged changes) and will then revert the working directory to HEAD.
It's not really related to the index/stage/cache except that it'll store away uncommitted changes that are in the cache.
This lets you quickly save the state of a dirty working directory and index so you can perform different work in a clean environment. Later you can get back the information in the stash object and apply it to your working directory (even if the working directory itself is in a different state).
The official git stash
manpage has pretty good detail, while remaining understandable. It also has good examples of scenarios of how stash
might be used.
这篇关于索引,缓存和在git中上演有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!