Uploading files to GitHub allows you to store anything on the repository. You can only upload files up to 25 MB in size to a repository using a web browser. Through the use of the command line, you can upload files up to 100 MB in size. Large files (more than 100 MB) must be uploaded using Git’s dedicated Large File Storage feature.
This article will give you clear and concise step by step for uploading files to GitHub. Make sure you follow each step carefully.
Table of Content
Things You Should Know About Uploading Files to GitHub
Uploading files to GitHub can be done directly on the GitHub website or by using Command Line.
- The maximum file size allowed in GitHub repositories is limited. For files larger than 50 MB, Git will issue a warning when you try to add or update them.
- Repositories should be kept modest; less than 1 GB is preferred, and fewer than 5 GB is strongly suggested.
How to Upload Files to GitHub Repository via Website
GitHub is a good platform that allows users to create and manage their repositories. You can follow the steps below on how to upload files to GitHub. Let’s check ‘em out!
- Access the repository’s homepage on GitHub.com.
- A drop-down menu titled “Add file“ will appear above the file list; select “Upload files” from this menu.
- Simply drop the files or directories you want to save in your repository into the file tree.
- Type a brief, descriptive commit message that explains the file edits you just made at the page’s end. The commit message might include credit for many authors.
- Choose between the existing branch and create a new one below the commit message fields. If the branch you’re working on is the default branch, you should make a new branch before committing and sending a pull request.
- To save your modifications, select Commit changes.
How to Upload Files to GitHub Repository via Command Line
If you have a file that you’d want to add to a repository on GitHub.com, you can do it using the command line. Command line is another method to upload files to GitHub, which is easy.
Note that before attempting this method, you should:
- Whether you’ve started your own GitHub repository or you’re looking to contribute to an existing one, you’re all set to go.
- You have successfully cloned the repository onto your own computer.
To upload a file to GitHub from your computer, navigate to the local directory you created while cloning the repository and copy the file there.
- Open Git Bash.
- Make a working directory change to your personal repository.
- Prepare the file to be added to your local repository.
$ git add .
# Adds the file to your local repository and stages it for commit. To unstage a file, use ‘git reset HEAD YOUR-FILE’.
- Finish up by committing the file you’ve been working on to a local repository.
$ git commit -m “Add existing file”
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use ‘git reset –soft HEAD~1’ and commit and add the file again.
- Changes in your local repository should be pushed to GitHub.com.
$ git push origin your-branch
# Pushes the changes in your local repository up to the remote repository you specified as the origin
Do not git add, commit, or push any sensitive information to a remote repository. Some examples of sensitive information are:
- Multiple files can be uploaded simultaneously to GitHub.
- Using GitHub to make changes to files in a repository’s protected branch is impossible.
- For other tips and tutorials on GitHub, read more on this page.