Step-by-step how to push your project in to github

🚀 The Absolute Beginner's Guide to Git and GitHub Push

This guide will walk you through the entire process of uploading your existing local project folder to GitHub, step-by-step.

🎯 Part 1: Initial Setup (The Essentials)

Before you begin, you need to ensure you have the basic tools installed and configured.

  1. GitHub Account If you don't have one, create an account on GitHub.
  2. Install Git (The Terminal Tool) Git is the program that performs the version control commands.
  • Download: Go to [git-scm.com/downloads]. Select your operating system (Windows/macOS/Linux).
  • Installation: For Windows: Run the installer and accept all default settings by clicking Next repeatedly. For macOS/Linux: Git is often pre-installed, or you can use the installer.
  • Verification: Open your Terminal (or Git Bash on Windows) and type: git --version. You should see the version number.
  1. Configure Your Identity This links your Git activity to your GitHub account.

Open your Terminal/Git Bash and execute these two commands, replacing the placeholders with your actual name and email registered on GitHub:

git config --global user.name "Your Name on GitHub"
git config --global user.email "your.email@example.com"

🌐 Part 2: Creating the Remote Repository in GitHub

You need a 'home' on GitHub for your project files.

  • Log in to your GitHub account.
  • In the top-right corner, click the + icon, and select New repository.
  • Fill in the details:
    • Repository name: Choose a short, descriptive name (e.g., my-first-website-project).
    • Visibility: Choose Public or Private.
    • Crucial Tip for Push: DO NOT check the box for "Add a README file" or any other files. We want the repository to be completely empty.
  • Click the green Create repository button.
  • GitHub will show you a page with "quick setup" instructions. Keep this page open! We will copy the commands from here later. You need a 'home' on GitHub for your project files.

📂 Part 3: Preparing Your Local Project Folder

Let's assume your project folder is located here:

Example Local Folder Location: C:\Users\YourName\Desktop\MyProjectFolder

  1. Navigate to Your Project Folder in the Terminal

You need to open your terminal and tell it to operate within your project folder.

  • Windows : Inside the MyProjectFolder, right-click on empty space and select Git Bash Here. or open terminal npm and run command cd C:\Users\YourName\Desktop\MyProjectFolder
  • macOS/Linux Open Terminal, then type cd and drag your project folder onto the terminal window. cd /Users/YourName/Desktop/MyProjectFolder After running the cd command, the prompt should indicate you are inside your project folder.
  1. Initialize Git Locally

This command turns your ordinary folder into a Git repository.

git init

Result: You will see a message like Initialized empty Git repository in ....

  1. Add Files to Staging

git add . (with a dot) means: "Add all new and modified files in this folder."

  1. Create the First Commit (Snapshot)

A commit is a recorded snapshot of your staged files. This action is local (only on your computer).

git commit -m "Initial project commit and setup"

The text in quotes ("...") is your commit message, describing the changes you made.

✅ Part 4: Connecting and Pushing to GitHub

Now you connect your local work to the empty repository you created in Part 2.

  1. Set the Branch Name

Modern Git uses main as the default branch name.

git branch -M main
  1. Connect the Remote Repository

Copy the git remote add origin ... command directly from the GitHub page you left open (in Part 2). It will look something like this (but with your username and repo name):

git remote add origin https://github.com/YourUsername/my-first-website-project.git
  1. Perform the Final Push!

This command finally uploads all your committed files to the GitHub server.

git push -u origin main

Authentication Alert: The first time you run this, a window/prompt will appear asking for your GitHub credentials.

Important: You may be required to use a Personal Access Token (PAT) instead of your regular password for security. If your password fails, you must generate a PAT from your GitHub settings and use that as the password.

Success!

Once the push is complete, you will see confirmation messages about the upload.

Action: Go back to your GitHub repository page and refresh the browser. Your project files (index.html, style.css, etc.) should now be visible online!

🔄 The Daily Workflow (Making Updates)

Whenever you make changes to your local project (e.g., you change index.html):

Stage the changes:

git add .

Commit the changes (record the snapshot):

git commit -m "Fixed typo on homepage header"

Push the changes to GitHub:

git push

ARTICLE BONUS :

🔑 Guide: How to Generate a Personal Access Token (PAT) on GitHub

GitHub stopped accepting regular account passwords for Git operations (like git push or git pull) via the command line in August 2021. Instead, they require a Personal Access Token (PAT) for security.

Here is the step-by-step process to create a PAT that you will use as your "password" during your first git push command.

  1. Step 1: Access Token Settings
  • Log in to your GitHub account using your web browser.
  • Click on your profile picture (avatar) in the upper right-hand corner.
  • Select Settings from the dropdown menu.
  • In the left sidebar, scroll down to the bottom and click Developer settings.
  • In the new left sidebar menu, click Personal access tokens.
  • Select Tokens (classic).
  1. Step 2: Start Generating a New Token
  • Click the green button Generate new token, and then select Generate new token (classic).
  • (Note: GitHub offers "Fine-grained tokens," but "Classic" is easier for beginners and is the common standard for simple repository access.)
  1. Step 3: Configure Your Token Settings You need to fill out three main sections on the token creation form: Note: Give it a descriptive name, such as: My-Laptop-PAT-for-Push. Expiration: Choose when the token should expire. Select 90 days or 1 year. Avoid "No expiration" for better security. Scopes(Permissions): This defines what the token is allowed to do. For pushing projects, you only need to check the repo scope (Full control of private repositories).

  2. Step 4: Generate and Copy the Token

  • Once you have filled in the details and checked the repo box, scroll down and click the green button Generate token.
  • GitHub will display the Token (a long string of random characters) on the next page.$$\text{Example: gh\_234jkln34jkl234jkln234jn243jkn123}$$
  • IMMEDIATELY COPY THIS TOKEN! This token will only be shown once. If you close this page, the token will be hidden, and you will have to generate a new one.Tip: Store this token securely (e.g., in a password manager or a temporary secure note).
  1. Step 5: Use the Token in the Terminal Return to your terminal (Git Bash/Command Prompt) where you ran the git push command:
    git push -u origin main
    
    • When the terminal prompts for your Username, enter your GitHub Username.
    • When the terminal prompts for your Password (or sometimes credential), paste the PAT you copied in Step 4.

The push process should now succeed. Git typically stores this credential securely on your computer (using the Git Credential Manager), so you won't need to enter the PAT every time you perform a subsequent git push.

Need a complete website anb blog with github and JAMSTACK SSG ?? you can hire our team dev

Order Static Site Generator Web Services