Beginner’s guide to GitHub: Uploading files and folders to GitHub (2024)

Welcome back to GitHub for Beginners, a series designed to help you navigate GitHub with ease.

If you’ve been following along, we’ve covered some basics of Git and GitHub, including the top Git commands every developer should know and how to create repositories. Now that you have a repository, you can use it to track file versions or collaborate with others. However, first you need to upload your files to the repository.

Let’s get started!

How do I upload files?

There are multiple ways you can upload content to GitHub, and we’ll go through a few of them. The first option we’ll cover is uploading using GitHub.com.

To upload a file to GitHub, you’re going to need a repository to upload the files to. We covered this in our previous how to create repositories blog, but as a quick refresher, you’ll need to click the button or menu option for creating a new repository. On the next screen, select an owner for the repository, give it a name, provide a description, choose whether it is public or private, and initialize it with a README.md file. Then, click the “Create repository” button.

Beginner’s guide to GitHub: Uploading files and folders to GitHub (1)

Once you’re in your repository, click on the plus button next to the green button that says “Code.” Select “Upload files” from the menu. On the next screen, click the link that says, “choose your files.” This opens up a file browser and you should select the files you want to upload.

Beginner’s guide to GitHub: Uploading files and folders to GitHub (2)

Depending on the size of the files, it might take a moment for them to upload, but you can see the files being added to your commit on the main screen. It’s important to realize these files aren’t uploaded to the repository yet. You still have a couple of short steps to go.

Next, add a commit message in the box under the list of files to be added. You can leave the default commit message, but it’s often helpful to provide a brief description of the changes you’re making. This gives anyone with access to your repository insight into what changes were made. Next, click the green button that says, “Commit changes.”

Now your files will be uploaded to your repository! This is a great way to add small files to GitHub. However, there’s another way that can be more convenient for uploading large files, folders, and entire projects.

How do I upload files using the terminal?

Before we use the terminal, we should create a new empty repository. In GitHub, click the plus button at the top and select “New repository.” This time, only enter a name and a description. We want the directory to be completely blank. We decided to call our repository python-game.

Click the green “Create repository” button.

Beginner’s guide to GitHub: Uploading files and folders to GitHub (3)

After your repository is created, you’ll see a window with some instructions and a list of Git commands you can use from a terminal. These are the steps we’re going to follow to push our files to GitHub.

Beginner’s guide to GitHub: Uploading files and folders to GitHub (4)

On your local machine, open a terminal and navigate to the project folder you want to upload. In our case, that’s the python-game directory, so we run cd python-game from the projects directory.

The first step is to run git init in the folder. git init initializes the folder and organizes it so that it can be used as a repository.

Next, we want to add a README.md file with a brief description, so let’s run touch README.md to create the file. You can now open the file (in the terminal or your file manager) and add a brief description that describes the repository.

Now, we need to tell Git which files to add to the repository. We do this by running the git add . command. This adds all of the files in our current directory to staging. The next step is to run git commit -m "initial commit" to create a commit with a description of “initial commit.” A commit is like a snapshot of the current state of the files in your local repository.

Beginner’s guide to GitHub: Uploading files and folders to GitHub (5)

To make sure everything worked, run git status and verify that all the files are ready to be pushed. You should see a message indicating that your working tree is clean.

Now, run git branch -M main to set the main branch. The next step is to connect your local repository to the repository on GitHub. You do this by running git remote add origin and replacing the with the URL provided on the GitHub instructions page when you created the repository. This essentially tells Git “this is where I want you to put these files.”

The final step is to run the git push -u origin main command. This sends all of the files to GitHub. Go back to your browser and refresh the page. You should see the files uploaded to GitHub and residing in your repository! Congratulations!

<img src="https://github.blog/wp-content/uploads/2024/06/git-add-cli-3.gif" alt="An animated gif showing "git status" and "git remote add origin

Now, if you already initialized Git in your project on your machine, and you just need to upload your files to a remote repository, you wouldn’t need to run git init at the start. You’d follow the rest of these steps, but skip that initial one.

What’s next?

Now that you have learned how to add files and folders to your repositories, it’s time to start using them to collaborate with others or add version tracking to your files!

If you have any questions, pop them in the GitHub Community thread and we’ll be sure to respond.

Here are some more resources to help you on your GitHub journey:

Tags:

  • GitHub for beginners
Beginner’s guide to GitHub: Uploading files and folders to GitHub (2024)

FAQs

How do I upload files and folders to GitHub? ›

On your computer, open the folder containing your work, then drag and drop all files and folders into the browser. At the bottom of the page, under "Commit changes", select "Commit directly to the main branch, then click Commit changes.

How do I move files from folder to folder in GitHub? ›

You can use the command line to move files within a repository by removing the file from the old location and then adding it in the new location. Many files can be moved directly on GitHub, but some files, such as images, require that you move them from the command line.

Why can't i upload large files to GitHub? ›

GitHub blocks files larger than 100 MiB. To track files beyond this limit, you must use Git Large File Storage (Git LFS). For more information, see "About Git Large File Storage." If you need to distribute large files within your repository, you can create releases on GitHub.com instead of tracking the files.

Can GitHub handle large files? ›

When you install GitHub Desktop, Git Large File Storage (Git LFS) is installed, too. Git LFS lets you push files to GitHub that exceed the normal limit of 100 MiB.

How do I Upload multiple files into GitHub? ›

On GitHub.com, navigate to the main page of the repository. Above the list of files, select the Add file dropdown menu and click Upload files. Alternatively, you can drag and drop files into your browser. To select the files you want to upload, drag and drop the file or folder, or click choose your files.

Can I add an entire folder to git? ›

Type "git add -A" and hit enter. This will add your folder and any new files to the staging area.

Can you upload an entire folder to GitHub? ›

Click "Add file" directly to the left of the green Code button. Next, add your folder by dragging it into this area or selecting "choose your files." Make sure to name your commit. You may also leave it blank if it is not necessary.

How do I add all files to a directory in GitHub? ›

To add and commit files to a Git repository

Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.

How do you add files to git? ›

To add and commit files to a Git repository

Create your new files or edit existing files in your local project directory. Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.

References

Top Articles
Wie man sicher mit Butylacrylat umgeht
Was ist ein K-Cup?
Tsukihime -A piece of blue glass moon- Review
Villarica Pawnshop Forex Rate
Madden 23 Solo Battles
Hallmark White Coat Ceremony Cards
Craigslist Placer County
Dyi Urban Dictionary
Keck Healthstream
Spur H0 » Details Trix H0 Profi Club Modell 2009
Weather Radar For East Coast
Urology Match Spreadsheet
Ups Cc Center
United Dual Complete Providers
Osrs Blessed Axe
8 Internet Celebrities who fell prey to Leaked Video Scandals
Spectrum Store Downey Photos
Kitchen Song Singer Violet Crossword
Pokemon Infinite Fusion Good Rod
Sand Castle Parents Guide
Estragon South End
5Ive Brother Cause Of Death
309 Marshall Passage
Stafford Rotoworld
Best Chinese Rome Ny
Open jazz : podcast et émission en replay | France Musique
Watch Fifty Shades Darker Online Putlocker
Softball History: Timeline & How it started
Elemental Showtimes Near Regal White Oak
Eddie Scozzare Salary
Craigslist Swm
Rochester Ny Missed Connections
Disney Cruise Line
Bustime B8
8 Farmhouse Classroom Essentials
Ktbs Payroll Login
Milwaukee Nickname Crossword Clue
14314 County Road 15 Holiday City Oh
Ring Of Endurance Osrs Ge
Kobe Express Bayside Lakes Photos
Susan Dey Today: A Look At The Iconic Actress And Her Legacy
Mireya Arboleda Net Worth 2024| Rachelparris.com
Fanart Tv
Weather Tomorrow Hourly At My Location On Netflix Movies
Rage Room Longmont
Marie Anne Thiebaud 2019
Montefiore Email Outlook Login
Kortni Floribama Shore Drugs
Victoria Maneskin Nuda
Sparkle Nails Phillipsburg
Busted Newspaper Lynchburg County VA Mugshots
James in Spanish | Spanish to Go
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6375

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.