This article is solely for newbies in Github regarding how to push large files to your Github repository.
GitHub does not allow us to upload files larger than 25 megabytes through the browser. If you try you may get an error as follows.
Nevertheless, you can push larger files into your Github repository using the git bash terminal as follows, in just 8 steps.
Download and install Git on your pc.
Download link:- https://git-scm.com/downloads
Then download and install GitLFS on your pc.
Download link: https://git-lfs.github.com/
Now clone your Github repository to your local machine.
First go to your repository and copy the ‘clone/download’ URL.
Next, create a new folder in your pc wherever you prefer: this is to clone the copy of your Github repository to your pc.
Then right-click the background and click ‘Git Bash Here’ as follows.
Then run the following command in the bash terminal opened.
$ git clone link you copiedEg:- $ git clone https://github.com/Newuser/NewRepository.git
Close the bash terminal and, now you have successfully cloned your GitHub repository to your local machine.
Go to inside the cloned repository. (If you want to upload the file to another folder already created inside the repository, then go to that folder)
Right-click the background and again click ‘Git Bash Here’.
Run the following command
$ git lfs track “.fileextension”Eg: If I want to upload a pdf file, then
$ git lfs track “.pdf”
Then copy the file you want to upload, into repository or folder in the repository.
Then run the command,
$ git add filename.fileextensionEg:- $ git add TheGuid.pdf
We should log into Github to push the file to the repository, run the following commands.
$ git config — global user.email “firstname.lastname@example.org”Eg:- $ git config — global user.email “email@example.com”
For this use your email address used in Github account.
$ git config — global user.name “your name”Eg:- $ git config — global user.name “George Bernard”
For this use your name in Github account. You can find your email and name in the settings of the Github account.
Then a window will pop out asking your Github email/user name and password. Enter the credentials and submit them.
Now run the following command.
$ git commit -m "add filename.fileextension"Eg:- $ git commit -m “add TheGuid.pdf”
$ git push origin masterThis command will start the uploading the file.
You will notice the progress of the uploading in the bash terminal as follows
After uploading is finished, you may notice the file is uploaded to your GitHub repository, successfully.