git大文件管理 LFS:Git Large File Storage

git大文件管理 LFS:Git Large File Storage

2023-3-28

git默认不支持大文件的管理,通过LFS的安装,可以很方便的管理大文件资料。

本文简单记录LFS的使用

1. 下载软件

官网:https://git-lfs.com/

2. 使用

在git仓库根目录,新建文件.gitattributes文件;

设置指定类型的文件,被LFS管理。

*.exe filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.msi filter=lfs diff=lfs merge=lfs -text

以上两步,基本就够用了。

3. 查看lfs的版本号

git lfs version

4. 版本不生效?

如果遇到版本不生效,可以试着把git-lfs.exe移动到git目录下

git大文件管理 LFS:Git Large File Storage_第1张图片

4. 如果有时间详细研究,请到官网

From source

  • Place the git-lfs binary on your system’s executable $PATH or equivalent.
  • Git LFS requires global configuration changes once per-machine. This can be done by
    running:
$ git lfs install

Example Usage

To begin using Git LFS within a Git repository that is not already configured
for Git LFS, you can indicate which files you would like Git LFS to manage.
This can be done by running the following from within a Git repository:

$ git lfs track "*.psd"

(Where *.psd is the pattern of filenames that you wish to track. You can read
more about this pattern syntax
here).

Note: the quotation marks surrounding the pattern are important to
prevent the glob pattern from being expanded by the shell.

After any invocation of git-lfs-track(1) or git-lfs-untrack(1), you must
commit changes to your .gitattributes file
. This can be done by running:

$ git add .gitattributes
$ git commit -m "track *.psd files using Git LFS"

You can now interact with your Git repository as usual, and Git LFS will take
care of managing your large files. For example, changing a file named my.psd
(tracked above via *.psd):

$ git add my.psd
$ git commit -m "add psd"

Tip: if you have large files already in your repository’s history, git lfs track will not track them retroactively. To migrate existing large files
in your history to use Git LFS, use git lfs migrate. For example:

$ git lfs migrate import --include="*.psd" --everything

You can confirm that Git LFS is managing your PSD file:

$ git lfs ls-files
3c2f7aedfb * my.psd

Once you’ve made your commits, push your files to the Git remote:

$ git push origin master
Uploading LFS objects: 100% (1/1), 810 B, 1.2 KB/s
# ...
To https://github.com/git-lfs/git-lfs-test
   67fcf6a..47b2002  master -> master

你可能感兴趣的:(开发软件技巧,Java,git,linux,github,gitlab)