跟踪文件和分段文件有什么区别? [英] What's the difference between a tracked and a staged file?

查看:150
本文介绍了跟踪文件和分段文件有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始阅读S. Chacon和B. Straub的书Pro Git。在第2章的部分记录对版本库的更改中,您会发现以下语句:


请记住,工作目录中的每个文件都可以处于两个
状态中的一个状态:已跟踪或未跟踪。跟踪文件是位于
上次快照中的文件;它们可以是未修改,修改或分段的。


由此,我得到的印象是跟踪文件集可能比演示文件的集合。但与此同时,当我查看此链接时,我可以看到声明下面的内容似乎与书中的内容相矛盾:


告诉Git开始跟踪对 octocat.txt所做的更改我们
首先需要使用 git add 将其添加到暂存区。



<这似乎表明每个阶段性文件都是一个跟踪文件,反之亦然。



我缺少什么?


你是对的,每一个上演的文件都是一个被追踪的文件,但是你错了,并不是每个被追踪的文件都上演了。

在暂存区域中,您收集构成下一个提交的更改。

因此,如果您修改一个文件并将其更改添加到索引,那么这个文件将被暂存,而所有其他已提交的文件也都是跟踪文件。


I've just started reading the book "Pro Git" by S. Chacon and B. Straub. On Chapter 2, in the Section Recording Changes to the Repository you'll find this statement:

Remember that each file in your working directory can be in one of two states: tracked or untracked. Tracked files are files that were in the last snapshot; they can be unmodified, modified, or staged.

From this, I got the impression that the set of tracked files may be bigger than the set of staged files. But at the same time when I look at this link, I can see the statement below which seems to contradict what's written in the book:

To tell Git to start tracking changes made to octocat.txt, we first need to add it to the staging area by using git add.

which appears to say that every staged file is a tracked file and vice-versa.

What am I missing?

解决方案

They do not contradict.
You are right, every staged file is a tracked file, but you are wrong, not every tracked file is staged.
In the staging area, you collect the changes that make up the next commit.
So if you modify one file and add its changes to the index, that one file is staged, while all other already commited files are also tracked files.

这篇关于跟踪文件和分段文件有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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