简体   繁体   English

git 根文件系统版本控制目录

[英]git version control directory of root file system

I have downloaded a tar file which is Linux-Sample-Root-Filesystem and extracted to a directory.I want to use git version control on the directory.But somehow file size is abnomal.我已经下载了一个 tar 文件,它是 Linux-Sample-Root-Filesystem 并解压缩到一个目录。我想在目录上使用 git 版本控制。但不知何故,文件大小异常。

The original size of directory is 3.6G then use git to control the directory(git add and commit).However it becomes 3.8G after checkout the HEAD.目录的原始大小是3.6G,然后使用git来控制目录(git add和commit)。但是签出HEAD后变成3.8G。

I also try git-lfs(Large File Storage),it doesn't work.我也尝试了 git-lfs(大文件存储),它不起作用。

How should I use git to control such a Linux-Sample-Root-Filesystem directory?我应该如何使用 git 来控制这样一个 Linux-Sample-Root-Filesystem 目录? Any piece of information,I will be so thankful for your help.任何信息,我将非常感谢您的帮助。

tar -xf Tegra_Linux_Sample-Root-Filesystem_R32.2.1_aarch64.tbz2  -C rootfs/

root@richard-VMBox:/home/richard/Desktop/example# du -sh rootfs/
3.6G    rootfs/    ####The rootfs directory total size is 3.6G. 

List of each sub-directories size.
root@richard-VMBox:/home/richard/Desktop/example/rootfs# du -sh */
12M     bin/
80K     boot/
4.0K    dev/
12M     etc/
4.0K    home/
353M    lib/
4.0K    media/
4.0K    mnt/
4.0K    opt/
4.0K    proc/
12K     root/
132K    run/
11M     sbin/
4.0K    snap/
4.0K    srv/
4.0K    sys/
4.0K    tmp/
3.1G    usr/
134M    var/
  • git add rootfs/ git 添加rootfs/
  • git commit -m "add rootfs/ dir" git commit -m "add rootfs/ dir"

 root@richard-VMBox:/home/richard/Desktop/example# rm -rf rootfs/ 

root@richard-VMBox:/home/richard/Desktop/example# git reset --hard HEAD ...Checking out files: 100% (113421/113421), done. HEAD is now at a65e1fe81 add rootfs dir root@richard-VMBox:/home/richard/Desktop/example# du -sh rootfs/ 3.8G rootfs/ ###File size is bigger. root@richard-VMBox:/home/richard/Desktop/example/rootfs# du -sh */ 12M bin/ 80K boot/ 4.0K dev/ 12M etc/ 4.0K home/ 335M lib/ 4.0K media/ 4.0K mnt/ 4.0K opt/ 4.0K proc/ 12K root/ 132K run/ 11M sbin/ 4.0K snap/ 4.0K srv/ 4.0K sys/ 4.0K tmp/ 3.3G usr/ 134M var/

In general, it's not a good idea to version control entire file systems.一般来说,对整个文件系统进行版本控制并不是一个好主意。 Version control tools like Git tend to work best on text files, and storing large binary files is not recommended.像 Git 这样的版本控制工具往往在文本文件上效果最好,不建议存储大型二进制文件。 Git also doesn't support things you may want like hard links, user and group permissions, or any permissions other than 644 and 755. Git 也不支持您可能想要的东西,例如硬链接、用户和组权限,或 644 和 755 以外的任何权限。

If you really want to do this, you may want to look into something like pristine-tar , which stores files and the difference between those files and the tarball itself.如果你真的想这样做,你可能想研究一下pristine-tar之类的东西,它存储文件以及这些文件与 tarball 本身之间的区别。

The reason you're seeing the increase in file size is because of the .git directory.您看到文件大小增加的原因是.git目录。 When you check files into Git, all the files and directories have their contents stored compressed inside the .git directory.当您将文件签入 Git 时,所有文件和目录都将其内容压缩存储在.git目录中。 As a result, the extra 200 MB is probably from that data being stored.因此,额外的 200 MB 可能来自正在存储的数据。

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

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