简体   繁体   English

“ git add”和“ git update-index”有什么区别

[英]What is the difference between “git add” and “git update-index”

What is the difference between "git add" and "git update-index"? “ git add”和“ git update-index”有什么区别?

Under what circumstances would I use one of these commands or the other? 在什么情况下我会使用其中一个命令?

To quote git help update-index : 引用git help update-index

See also git-add(1) for a more user-friendly way to do some of the most common operations on the index. 另请参阅git-add(1)以获得更友好的方式来对索引执行一些最常见的操作。

So git add is the thing you normally use, while git update-index is the more powerful variant that also requires more knowledge on your side. 因此, git add是您通常使用的东西,而git update-index是更强大的变体,它也需要您更多的知识。

NB. NB。 It really pays off to get used to the git help command, the help pages of git are excellent . 习惯git help命令真的很值得, git help的帮助页面非常出色

Basically, update-index is a plumbing command - it means, low-level. 基本上, update-index是一个管道命令-这意味着它是低级的。 git add internally uses update-index . git add内部使用update-index I believe, that 我相信

git add <file> is the same as git update-index --add <file> git add <file>git update-index --add <file>

One of the circumstances, when I use update-index, is when you have a change to a file, which you don't want to commit - in this case you can run 在我使用update-index的情况下,一种情况是您更改了不想提交的文件-在这种情况下,您可以运行

git update-index --assume-unchanged <file>

So if you run git status after that, you'll see, that file not in the list of changed files. 因此,如果在此之后运行git status ,则会看到该文件不在更改的文件列表中。

More here How to manage configuration files when collaborating? 更多信息协作时如何管理配置文件?

and here http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html 和这里http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM