Git & GitHub First-Time Setup
Version control from scratch in 20 minutes
beginner2 min read
gitgithubversion-controlsetupswe
Git is a version control system — it tracks every change you make to your code so you can go back in time if something breaks. GitHub is where you store your code online and collaborate with others.
Step 1: Install Git
- 1Mac: Open Terminal and run the command below. If prompted, install Xcode Command Line Tools
- 2Windows: Download Git from git-scm.com and run the installer (accept defaults)
- 3Verify installation by running: git --version
macOS
$xcode-select --install
Terminal
$git --version
Step 2: Configure your identity
- 1Git needs to know who you are so it can label your changes
- 2Run the two commands below with YOUR name and email
- 3Use the same email you'll use for GitHub
Terminal
$git config --global user.name "Your Name"
Terminal
$git config --global user.email "you@example.com"
Step 3: Create a GitHub account
- 1Go to github.com and sign up for a free account
- 2Choose a username you'll be happy with — it becomes your developer identity
- 3Verify your email address
Step 4: Your first repository
- 1Create a new folder for your project and navigate into it
- 2Run 'git init' to initialize Git tracking in this folder
- 3Create a file (e.g., README.md)
- 4Stage the file with 'git add README.md'
- 5Create your first commit with the message below
Terminal
$mkdir my-first-repo && cd my-first-repo && git init
Terminal
$echo '# My First Repo' > README.md
Terminal
$git add README.md && git commit -m 'Initial commit'
✓The basic Git workflow
The daily cycle is simple: edit files → stage changes (
git add) → commit (git commit) → push to GitHub (git push).Step 5: Push to GitHub
- 1On GitHub, click the '+' button and select 'New repository'
- 2Name it the same as your local folder, leave it public, DON'T initialize with a README
- 3GitHub will show you commands to push — run the ones below (replace YOUR_USERNAME)
Terminal
$git remote add origin https://github.com/YOUR_USERNAME/my-first-repo.git
Terminal
$git push -u origin main
Congratulations! You now have version control set up and your code is backed up on GitHub. As you continue coding, remember to commit your changes frequently — think of commits like save points in a video game.