为什么结账和重置会改变索引? [英] Why do checkout and reset change the index?

查看:103
本文介绍了为什么结账和重置会改变索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为索引只是针对下一次提交的文件而已,但重置和签出也会更新索引:

git checkout


为了做好准备,通过更新索引和工作树中的文件来切换到它,



解决方案

这个想法是,git总是提交当前状态的快照,而不仅仅是差异。因此,在进行结帐时,索引将被更新为包含您刚刚签出的内容的快照,然后更改添加文件/更改。



我的问题是因为我在不正确的假设下操作,只有变化才会被添加到索引中。


I thought that the index is just for the files you staged for the next commit, but both reset and checkout also update the index:

git checkout

To prepare for working on , switch to it by updating the index and the files in the working tree,

解决方案

The idea is that git always commits snapshots of the current state and not just diffs. So when doing a checkout, the index will be updated to contain a snapshot of what you just checked out, which you then change adding files/changes.

My question is because I operated under the incorrect assumption that only changes would be added to the index.

这篇关于为什么结账和重置会改变索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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