How to Set Up Git Bash and Push Your First Project

A beginner’s guide to mastering version control on Windows.

Step 1: Download and Install Git

First, you need the software that allows your computer to speak “Git.”

  1. Download: Go to git-scm.com and download the Windows installer.

  2. Install: Run the .exe file. You can keep most settings as “Default,” but ensure “Git Bash” is selected.

  3. Verify: Once installed, right-click anywhere on your desktop and select “Git Bash Here.” A black terminal window should open.

Step 2: Configure Your Identity

Before you write code, Git needs to know who you are so it can label your work.

In your Git Bash window, type these two commands (replace with your info):

Bash

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

Step 3: Create Your Online Repository

Before uploading, you need a “home” for your code on the web.

  1. Log in to GitHub (or Azure/GitLab).

  2. Click the “+” icon and select New repository.

  3. Give it a name and click Create repository.

  4. Copy the URL (e.g., https://github.com/username/project.git).


Step 4: Prepare Your Local Folder

Navigate to your project folder on your computer. Right-click inside that folder and choose Git Bash Here. Now, run these “The Big Three” commands:

1. Initialize

This creates a hidden .git folder that starts tracking changes.

Bash

git init

2. Stage (Add)

This tells Git, “I want to include these files in my next snapshot.”

Bash

git add .

3. Commit

This takes the snapshot and saves it to your local history.

Bash

git commit -m "My first commit"

Step 5: Connect and Push to the Cloud

Now, send your local files to the online repository you created in Step 3.

  1. Link the two: (Paste your copied URL here)

    Bash

    git remote add origin https://github.com/YourUsername/YourRepo.git
    
  2. Push the code:

    Bash

    git branch -M main
    git push -u origin main
    

Note: A popup will appear asking you to sign in to your GitHub/Azure account. Once you log in, your files will be live!


Summary Checklist

Command What it does
git init Starts a new Git project.
git add . Selects all files for the “upload.”
git commit -m "..." Saves the snapshot locally.
git push Sends the files to the internet.
Share This Post:

Leave a Comment