Creating a GitHub repository from a local folder involves a few steps. You’ll need to have Git installed on your computer and be logged into your GitHub account. Here’s a step-by-step guide:

Step 1: Install Git

If you don’t already have Git installed on your computer, you can download and install it from the official website: Git Downloads.

Step 2: Open a Terminal or Command Prompt

You’ll need to use a command-line interface (Terminal on macOS/Linux, Command Prompt on Windows) to execute Git commands.

Step 3: Navigate to Your Local Folder

Use the cd (change directory) command to navigate to the local folder that contains the files you want to include in your GitHub repository. For example:

cd /path/to/your/local/folder

Replace /path/to/your/local/folder with the actual path to your local folder.

Step 4: Initialize a Git Repository

To make your local folder a Git repository, use the following command:

git init

This command initializes a new Git repository in your local folder.

Step 5: Add Files to the Staging Area

Use the following command to add your files to the staging area. Replace <file> with the name of the file you want to add, or use a dot . to add all files in the current directory:

git add <file>

For example, to add all files:

git add .

Step 6: Commit Changes

Commit your changes with a meaningful commit message:

git commit -m "Initial commit"

Replace "Initial commit" with a descriptive message that explains the purpose of this commit.

Step 7: Create a New Repository on GitHub

Go to the GitHub website and log in to your account.

Step 8: Create a New Repository

Click the “+” icon in the top right corner of the GitHub homepage and select “New repository.” Fill in the repository name, description, and other settings.

Step 9: Create Repository

Click the “Create repository” button to create the GitHub repository.

Step 10: Link Local Repository to GitHub Repository

Back in your command-line interface, link your local Git repository to the newly created GitHub repository. Replace <username> with your GitHub username and <repository> with the repository name you created in step 8:

git remote add origin<username>/<repository>.git

For example:

git remote add origin

Step 11: Push to GitHub

Finally, push your local repository to GitHub:

git push -u origin master

You might be prompted to enter your GitHub username and password for authentication.

After completing these steps, your local folder and its contents will be on GitHub as a new repository. You can now manage your project’s source code using Git and GitHub.

By Ray Lee (System Analyst)

iDempeire ERP Contributor, 經濟部中小企業處財務管理顧問 李寶瑞

One thought on “How to Create a GitHub Repository from a Local Folder”

Leave a Reply

Your email address will not be published. Required fields are marked *