Home > Common Problem > How to install Git LFS on WSL2 – Windows 11 or 10?

How to install Git LFS on WSL2 – Windows 11 or 10?

王林
Release: 2023-09-17 10:53:07
forward
1324 people have browsed it

1. Install Ubuntu WSL 2 or 1

I assume you have already downloaded and installed Ubuntu on the Windows Subsystem for Linux to run on.

2. Run System Update

Once you have WSL running with Ubuntu bash, go to the Windows search box and type – Ubuntu to run it. When opened, first execute the system update command. Not only does it install available updates, it also rebuilds the APT package repository cache.

sudo apt update && sudo apt upgrade -y
Copy after login

3. Install Git LFS on Ubuntu WSL 2 or 1

Git LFS is available through the system default repository of Ubuntu 22.04/20.04, so we can use the system repository and APT packages Manager installs it easily. Here are the commands to follow:

sudo apt install git-lfs
Copy after login
如何在 WSL2 – Windows 11 或 10 上安装 Git LFS?

4. How to use Git LFS

After installing Git LFS, you can check its man page to find out what it does Commands on GitHub. For a quick overview, users can also use the given command:

git lfs help
Copy after login

However, below is an overview of the steps involved in getting started with Git LFS.

1. Initialize Git LFS in the Git repository: To do this, switch to the root directory of the Git project and run the given command to initialize Git LFS once for the Git repository.

git lfs install
Copy after login

This command will set up Git LFS on the repository and configure Git to use Git LFS for large files.

2. Configure Git LFS: We need to create a file in the root directory of the Git repository to

Configure Git LFS to track the specific types of files we want to store in the remote server. After creating the file, add the file types that you want to track with LFS. .gitattributes

For example , if we want to track all files with extension .mp4, we can add the following to your file Line: .gitattributes

*.mp4 filter=lfs diff=lfs merge=lfs -text
Copy after login
3. Adding and committing large files: After configuring the

.gitattributes file with the file type we want it to track, you can process it like normal Files will be large filesadded and submitted to the repository. Git LFS will automatically replace these large files with pointer files and upload the actual file contents to the Git LFS server.

4. Pushing and pulling changes: When you push or pull changes from the repository, Git LFS handles the transfer of large files in the background. If you want to push changes to a remote repository, you need to ensure that Git LFS is also installed and configured on the remote server.

It is recommended to use Git LFS for files larger than 100MB, as for smaller files it may be more efficient to store them directly in Git.

The above is the detailed content of How to install Git LFS on WSL2 – Windows 11 or 10?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yundongfang.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template