Skip to main content

Git Setup & Your First Repo

It’s time to stop reading and start doing! In this guide, we will transform your computer into a developer workstation.

Step 1: Install Git

First, we need to get the Git engine running on your machine.

  1. Download the Git for Windows installer.
  2. Run the .exe file.
  3. Important: When asked about the "Default Editor," you can choose Visual Studio Code.
  4. Keep all other settings as "Default" and click Install.

Step 2: Configure Your Identity

Git needs to know who is making changes. Open your terminal (or Git Bash on Windows) and type these two lines:

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

Note: Use the same email address you plan to use for your GitHub account.

Step 3: Create Your First Repository

Let's create a "Hello World" project and track it with Git.

1. Create a Folder

mkdir my-first-repo
cd my-first-repo

2. Initialize Git

This creates a hidden .git folder. This is where the "Time Machine" lives!

git init

3. Create a File

Create a simple file named hello.txt and add some text to it.

4. The Magic Sequence (Add & Commit)

# Add the file to the Staging Area
git add hello.txt

# Save the snapshot to the Local Repository
git commit -m "feat: my very first commit"

Step 4: Connect to GitHub

Now, let's put your code in the cloud so the world can see it.

  1. Go to GitHub.com and create a free account.
  2. Click the + icon in the top right and select New Repository.
  3. Name it my-first-repo and click Create repository.
  4. GitHub will give you a "Remote URL" (it looks like https://github.com/your-username/my-first-repo.git).

Run these commands in your terminal to link your computer to GitHub:

# Link your local repo to the cloud
git remote add origin https://github.com/your-username/my-first-repo.git

# Rename your main branch to 'main' (standard practice)
git branch -M main

# Upload your code!
git push -u origin main

How to Check Your Work

Refresh your GitHub repository page. You should see your hello.txt file sitting there!

Common Commands Cheat Sheet

CommandPurpose
git statusSee which files are modified or staged.
git logSee the history of all your commits.
git diffSee exactly what lines changed in your files.
git branchList your current branches.
🎉 Congratulations!

You are now officially using Version Control. You have a local history on your computer and a backup in the cloud. You are ready to start building real backend applications!