git跟踪和git分级的概念 [英] Concept of git tracking and git staging
问题描述
在工作目录中修改文件时,git会告诉您使用git add来登台。
将新文件添加到工作目录,git告诉你使用git add来开始跟踪。
我对这两个概念有点困惑,因为我认为跟踪文件的变化与分段不同它提交
Git有一个被称为'索引'的概念。要创建一个新的提交,你需要在下一个提交中填入你想要的内容。这意味着您必须通过使用 git add
来明确告诉Git您希望在下一次提交中出现哪些更改。 ( git add -p
仅添加单个区块)
无论您是否使用Git只更新一个文件(»stage changes«),或者如果你添加一个新文件的全部内容(»开始跟踪一个文件«) - 这两次,Git的索引看到的所有内容都是新增的更改
When you modify a file in your working directory, git tells you to use "git add" to stage.
When you add a new file to your working directory, git tells you to use "git add" to start tracking.
I am a bit confused about these 2 concepts because i assumed tracking a file for changes is different from staging it for commit
Git has a concept known as 'the index'. To create a new commit, you fill the index with the contents you'd like to have in the next commit. That means that you have to explicitly tell Git which changes you want to appear in the next commit by using git add
. (git add -p
to add only single hunks)
It doesn't make a difference to Git whether you only update a file (»stage changes«) or if you add the full content of a new file (»start tracking a file«) – both times, all that Git's index sees is the addition of new changes
这篇关于git跟踪和git分级的概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!