问题
What file metadata is preserved by Git?
What is from ACL, owner, group ID, file permissions, atime, ctime, mtime preserved in Git history?
As I know there is special handling for executable permission:
git add --chmod=+x one.txt
git add --chmod=-x two.txt
Is anything else preserved by Git?
回答1:
Virtually none.
Git will look at the x
bits in the result of stat
. If any of the three are set, Git will save the file using a tree entry in which the mode
is 100755
. Otherwise Git will save the file using a tree entry in which the mode
is 100644
.
This does not depend on any of the other mode bits (except that the file must be a file, not a directory—Git does not save directories—nor a symbolic link). A file whose actual mode is 100
(--x------
) is saved as 100755
.
回答2:
Only executable bit. Git concentrates on storing file content.
If you need to preserve something else you have to to do it yourself or use some kind of metadata helpers like metastore or gibak.
来源:https://stackoverflow.com/questions/45578579/what-file-metadata-is-preserved-by-git