How to upload/push large files in GitHub
The Introduction
GitHub is the most popular VCS (Version Control System) out there. This is tough to find any single developer without VCS. Most of the time we use it to store our codebase in an organized way. It’s also known for collaborative work on projects.
Many of the time the size of your projects might go big depending on the projects. GitHub standard way limits upload size to 25 MB.
So now the question is, how we can upload file sizes of more than 25 MB?
Ok, fine. There have been plenty of doing this. I am going to use GitLfs (Large File System). So let’s do it…
Install Prerequisites:-
- Git
sudo pacman -S git
2. GitLfs
sudo pacman -S git-lfs
How to Upload Large Files in GitHub?
First, navigate to the folder where your files are present. Open a terminal or command prompt. I am using an Arch-based Linux distro.
1.
git init
To initialize git on your directory.
2.
git lfs track "*.pt"
It will track the file of the given extension. In my case, the extension of the file is .pt, it might be different in your case. For example .apk, .gif etc.
3.
git add .gitattributes
Add the extension of your files.
4.
git add *.pt
It adds all the files in the format you have given.
5.
git config - global user.email "user_github_mail_address"
Add your github mail address.
6.
git config - global user.name "user_name"
Add your github username.
7.
git commit -m "Adding pt file"
Add a message whatever you want.
8.
git remote add origin "link_of_your_repo"
Add the link to your github repository.
9.
git push origin master --force
Use force flags if your repository isn’t empty. Otherwise isn’t required.
Before pushing code to the repo repository it will ask for your username and password.
- First, specify your github username.
- Create a token for your repo. It’s not your github password! To create a token go to settings on your github account. Scroll down at bottom of the left side and click on Developer settings then on the left side click Personal access token -> Tokens (Classic) then generate a token and copy that token and paste it into your password input.
Congratulations 👏 you have successfully uploaded large files in your GitHub account.