DevOps
GitHub
Uploading a Project

How to Upload a Project to GitHub

Moving your local project to GitHub allows you to save your work in the cloud, track changes over time, and collaborate with others. This guide covers the standard process for your first upload.


🏗️ Step 1: Local Preparation

Before moving to the cloud, ensure your local folder is a Git repository and contains a snapshot of your code.

  1. Initialize Git:
    git init
  2. Add Files: Stage all your files for the first commit.
    git add .
  3. Internal Snapshot: Create the initial commit.
    git commit -m "Initial commit"

🌐 Step 2: Create a Repository on GitHub

  1. Log in to your GitHub account (opens in a new tab).
  2. Click the + icon in the top-right corner and select New repository.
  3. Give your repository a name (e.g., my-devops-project).
  4. Click Create repository.

🔗 Step 3: Connect Local to Remote

Once the GitHub repo is created, you will see a URL (e.g., https://github.com/user/repo.git). Use this to link your local folder to GitHub.

  1. Add Remote Origin:
    git remote add origin https://github.com/your-username/your-repo-name.git
  2. Rename Default Branch: Ensure your default branch is named main (the modern standard).
    git branch -M main

🚀 Step 4: The Final Push

Now, upload your local commits to the GitHub server.

git push -u origin main

[!NOTE] The -u flag sets the upstream tracking, meaning next time you can just type git push or git pull and Git will know exactly which branch and remote to use.


✅ Step 5: Verification

Refresh your GitHub repository page in your browser. You should now see all your local files, your commit message, and the project history listed on the site!


[!IMPORTANT] Authentication If you haven't set up your SSH keys yet, check out our SSH Key Setup Guide to avoid entering your password every time you push.