git store如何提交 - 如何保存更改?

时间:2015-06-30 10:08:28

标签: git

当git提交时,它只在.git目录中反映了已更改的文件或所有项目文件?

为什么git gc在每次提交后都没有出现? 这个命令的创建是什么?

1 个答案:

答案 0 :(得分:0)

Every version of every file is stored in the .git directory. So let's say you have three files in there: A1, B1, and C1. Then you do a commit that changes A1 to A2. After that, .git will contain A1, B1, C1, and A2. So all project files are indeed in the .git directory, but only one was added, because only one was changed.

Two reasons I can think of offhand why git gc is not run after every commit is a) it takes time and b) it gets rids of files that you may want to retrieve later. You can think of git gc as being like emptying your recycle bin on Windows; it prevents you from easily "undeleting" files later on.