To use Git LFS for a specific repository, you need to follow these steps:
- Install Git LFS: If you haven’t already, you need to install Git LFS on your system. You can download and install it from the official website: Git LFS Installation.
- Initialize Git LFS in your repository: Navigate to your local repository directory using the command line and run the following command to initialize Git LFS:bashCopy code
git lfs install
- Track large files: Identify the large files you want to track with Git LFS and specify them in your repository’s
.gitattributes
file. If you don’t have a.gitattributes
file, you can create one in the root of your repository.For example, if you want to track all files with the.psd
extension, you can add the following line to your.gitattributes
file:scssCopy code*.psd filter=lfs diff=lfs merge=lfs -text
This tells Git LFS to track files with the.psd
extension. - Add and commit your changes: After specifying the files to track with Git LFS, add and commit your changes to the repository as usual:bashCopy code
git add .gitattributes git commit -m "Enable Git LFS for large files"
- Push your changes to GitHub: Once you’ve committed your changes, push them to your GitHub repository:bashCopy code
git push origin <branch-name>
Replace<branch-name>
with the name of the branch you want to push your changes to, typicallymain
ormaster
. - Verify on GitHub: After pushing your changes, verify that Git LFS is working as expected by checking your repository on GitHub. You should see that large files tracked by Git LFS are stored separately from the rest of your repository’s files.
By following these steps, you can use Git LFS to manage large files in a specific GitHub repository.