克隆存储库时的 .gitattributes
.gitattributes when cloning repository
讨论 the propagation of changes to .gitattribute to other repos 让我开始思考。如果我正在克隆具有 .git 属性的现有存储库怎么办?
此文件可能会指定 git 哪些文件被视为文本,哪些不是。当我克隆此存储库时,git 是否确保在签出文件之前读取此文件并使其生效?
我做了一些实验,它似乎像我预期的那样有效。
这有任何记录吗?
PS:.gitattributes文件是否影响自身不在本题范围内
Checking-out and checking-in
These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as git checkout and git merge run. They also affect how Git stores the contents you prepare in the working tree in the repository upon git add and git commit.
When I clone [a] repository [in which the commit that I will choose for git checkout
has a .gitattributes
file in it], does git make sure to read this file and make it effective before checking out files?
是的。
Is this documented anywhere?
是的,朝向the gitattributes documentation的前方:
When the .gitattributes
file is missing from the work tree, the path in the index is used as a fall-back. During checkout process, .gitattributes
in the index is used and then the file in the working tree is used as a fall-back.
这里有一点不清楚,因为索引本身与工作树填充是半同时填充的——整个事情就像通过一个大的原子事务一样完成——但事实上,这意味着什么Git 从提交创建索引1,然后使用索引中的内容填充工作树。
1这个"the"索引实际上是新的索引,存储在index.lock
中,将稍后通过原子重命名()操作成为索引。但是,在发生任何事情之前,Git 必须扫描整个工作树并验证是否允许工作树更新,然后以伪原子方式执行工作树更新,然后 将 index.lock
文件重命名为 index
以导致原子事务通过释放锁来提交。
讨论 the propagation of changes to .gitattribute to other repos 让我开始思考。如果我正在克隆具有 .git 属性的现有存储库怎么办?
此文件可能会指定 git 哪些文件被视为文本,哪些不是。当我克隆此存储库时,git 是否确保在签出文件之前读取此文件并使其生效?
我做了一些实验,它似乎像我预期的那样有效。
这有任何记录吗?
PS:.gitattributes文件是否影响自身不在本题范围内
Checking-out and checking-in
These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as git checkout and git merge run. They also affect how Git stores the contents you prepare in the working tree in the repository upon git add and git commit.
When I clone [a] repository [in which the commit that I will choose for
git checkout
has a.gitattributes
file in it], does git make sure to read this file and make it effective before checking out files?
是的。
Is this documented anywhere?
是的,朝向the gitattributes documentation的前方:
When the
.gitattributes
file is missing from the work tree, the path in the index is used as a fall-back. During checkout process,.gitattributes
in the index is used and then the file in the working tree is used as a fall-back.
这里有一点不清楚,因为索引本身与工作树填充是半同时填充的——整个事情就像通过一个大的原子事务一样完成——但事实上,这意味着什么Git 从提交创建索引1,然后使用索引中的内容填充工作树。
1这个"the"索引实际上是新的索引,存储在index.lock
中,将稍后通过原子重命名()操作成为索引。但是,在发生任何事情之前,Git 必须扫描整个工作树并验证是否允许工作树更新,然后以伪原子方式执行工作树更新,然后 将 index.lock
文件重命名为 index
以导致原子事务通过释放锁来提交。