Versioning Large File in Git

I want to introduce you Git LFS, it is a command line extension and specification for managing large files with Git. LFS is great for large, changing files, there is basically a text pointer to the large file archived some place else.

Install Git LFS

Note: you need to install Git LFS if you git pull from a remote repository that has it

For example, I am working on a RHEL machine.
First go to source page, follow the installation guide to install:

This will create a yum repos for git-lfs:

yum install -y git-lfs

you can see git-lfs is installed in your machine:

Once downloaded and installed, set up Git LFS and its respective hooks by running:

git lfs install

Note: You'll need to run this in your repository directory, once per repository.

Track Large File

Select the file types you'd like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime.

git lfs track "*.tar.gz"

Note: run this track command at the top level of your repository, then you need to git add .gitattributes file

Manage Large File

Then, just do normal git add and git commit to manage your large size file.

git add *.tar.gz
git commit -m "add tar.gz file"
git push origin <your branch>

Actually, you can check the large files you managed by running:

git lfs ls-files

猜你喜欢

转载自www.cnblogs.com/chengdol/p/10428938.html