How to add files to your GitHub repository
Tags: beginners, github, git, tutorial
Published: 2022-07-01 11:54:46

You can add files to your repository from GitHub or the command line in Git. Use GitHub if the file you’re adding is anything below 25MB. But if it does exceed 25MB, you might want to use the command line. You can add a file of up to 100MB using the command line. 

In this How-to guide, you’ll learn how to add files to your repository from GitHub and the command line. 

## Add files to your repository from GitHub

(1) Open your GitHub profile and go to the repository to which you want to add the files. 

(2) Click **Add file** to reveal a drop-down.

(3) Click **Upload files** in the drop-down. 

![Create new file screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3uekl7q6nsgz6xghbkfv.png)

(4) Pick, drag, and release the files in the area below. Or click **choose your files** to upload directly from your local machine. 


![Drag files to GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c39197fyv15fevb4hv0u.png)

(5) In the comment box, write your commit message. At this point, you can either commit directly to the master branch or create a new branch and start a pull request. It’s not a good practice to commit changes directly to the main branch, especially when you aren’t working solo. You can click **Learn more about pull requests** for more information.


![Commit message screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l5hc3bhv11yc38jzrqyh.png)

(6) Click **Commit changes**.

## Add files to your repository from the command line

This guide assumes you’ve installed and set up Git on your computer.  

(1) On GitHub, navigate to the repository to which you want to add a file and open it. 

(2) Highlight the HTTPS link and copy. 


![Link copy screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nfo8dgq5g7z0xdvevqoq.png)

(3) Open Git Bash on your computer. 

(4) Enter cd ~/Name of the location where you want your cloned repository. I chose “Desktop” as the preferred destination in the image below. 


![Desktop](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gjgncmx92dhn035kehlp.png)

(5) Type "git clone" and paste the link you copied from GitHub. 


![Git clone screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvn8gicxmrv2b6j0cq0v.png)

(6) Press enter. 


![Done cloning screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxrw7kimgmlla7rf0in7.png)

(7) Move the files of your choice into the local directory created when you cloned the repository. 

(8) Change your current working directory to your local repository, manually or from the command line in Git Bash. To do this from the command line, enter **cd ~/Desktop/Exercise** in Git Bash and press enter. Replace “Exercise” with the name of your local directory. 


![Master screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stmrwdg6wf5tn2tclggd.png)

(9) To stage the files for commit to your local repository, enter **git add .**. To check the status, enter **git status** and press enter (git status gives you a view of the staged files).


![Git status screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fr3nnqp8yps5idghlbz.png)

(10) To commit the file in your local repository, **enter git commit -m “Commit message”**. 


![Git commit screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzp214aagxiz1bl5qudo.png)

(11) To push changes from your local repository to your remote repository on GitHub, enter **git push origin your branch name**.


![Git Push](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aufunhg8gl5ancxpgdly.png) 

(12) Navigate to GitHub and check out your new file.