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目录下

在这里插入图片描述

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Goldchenn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值