How to Upload Files and Folders to GitHub: A Beginner's Guide - Blockchain.News

How to Upload Files and Folders to GitHub: A Beginner's Guide

James Ding Jul 08, 2024 12:51

Learn how to upload files and folders to GitHub repositories using GitHub.com and the terminal. Detailed steps for beginners.

How to Upload Files and Folders to GitHub: A Beginner's Guide

Uploading files and folders to GitHub is a fundamental skill for developers, allowing for efficient version control and collaboration. This guide, based on a blog post from The GitHub Blog, provides a comprehensive overview of the process for beginners.

How do I upload files?

There are multiple ways to upload content to GitHub. The first method is through GitHub.com:

1. Create a repository by clicking the button or menu option for creating a new repository. Provide necessary information like the repository name, description, and visibility settings, then initialize it with a README.md file. Click “Create repository.”

2. In your repository, click the plus button next to the green “Code” button and select “Upload files.” Choose the files you want to upload using the file browser.

3. Add a commit message describing the changes and click “Commit changes.”

This method is ideal for small files. For larger files, folders, or entire projects, the terminal might be more convenient.

How do I upload files using the terminal?

Follow these steps to upload files using the terminal:

1. Create a new empty repository on GitHub by clicking the plus button and selecting “New repository.” Enter a name and description, then click the “Create repository” button.

2. Open a terminal on your local machine and navigate to your project folder.

3. Initialize the folder as a Git repository using git init.

4. Create a README.md file with a brief description using touch README.md.

5. Add the files to the repository with git add ..

6. Commit the files with a message using git commit -m "initial commit".

7. Set the main branch using git branch -M main.

8. Connect your local repository to the GitHub repository using git remote add origin <URL> (replace <URL> with your repository URL).

9. Push the files to GitHub using git push -u origin main.

Refresh your GitHub page to see the uploaded files in your repository.

What’s next?

With the knowledge of uploading files and folders to GitHub, developers can start using repositories for collaboration and version tracking. For further learning, GitHub offers a variety of resources, including community threads and tutorials.

Image source: Shutterstock