DEV Community

Cover image for Git and GitHub Crash Course for Express.js Developers
Bello Osagie
Bello Osagie

Posted on • Edited on

Git and GitHub Crash Course for Express.js Developers

A practical guide to version control, GitHub CLI, and managing branches using Git and GitHub with Express.js projects — no fluff, just real-world workflow.


Introduction

Whether you're a beginner or working your way through a Node.js + Express.js project, using Git and GitHub is essential for version control and team collaboration. In this guide, you’ll learn how to:

  • Set up Git and GitHub from scratch
  • Use Git in the terminal
  • Use GitHub CLI to create and manage remote repositories
  • Connect your local project to GitHub
  • Create and switch between branches
  • Work with GitHub directly from your browser via GitHub.dev and VSCode.dev

This guide is hands-on and practical — no prior Git knowledge needed!


Prerequisites

Make sure you have the following installed:

  • Git (brew install git on macOS, choco install git on Windows)
  • GitHub CLI (gh)
  • A GitHub account

You can also use:


Step-by-Step Guide

1. Create or Sign In to Your GitHub Account

If you don’t already have a GitHub account, sign up here. This will allow you to push your code to the cloud and collaborate with others.


2. Open VSCode.dev or GitHub.dev

  • Visit https://vscode.dev for a blank editor
  • Or go to any GitHub repo and press . to open github.dev (web-based IDE)

Great for quick edits without local setup.


3. Initialize Git in Your Local Project

Navigate to your Express project folder and run:

git init
Enter fullscreen mode Exit fullscreen mode

This sets up a .git directory and prepares your project for version control.


4. Configure Git Author Info

Set your username and email. You can use --local (for this project) or --global (applies to all repos):

git config --local user.name "Your Name"
git config --local user.email "you@example.com"
Enter fullscreen mode Exit fullscreen mode

To confirm config:

git config --list
Enter fullscreen mode Exit fullscreen mode

5. Stage and Commit Your Changes

Add all files:

git add .
Enter fullscreen mode Exit fullscreen mode

Commit them:

git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

6. Create a GitHub Repository Using GitHub CLI

Use gh (GitHub CLI) to create a new repo:

gh repo create your-repo-name --public --source=. --push
Enter fullscreen mode Exit fullscreen mode

This automatically:

  • Creates the repo on GitHub
  • Connects it to your local repo
  • Pushes your code

If you don’t have the GitHub CLI yet:

brew install gh  # on macOS
choco install gh  # on Windows
Enter fullscreen mode Exit fullscreen mode

7. Create and Switch to a New Branch

git checkout -b feature/branch-name
Enter fullscreen mode Exit fullscreen mode

Example:

git checkout -b feature/2025/01-basic-dev-setup
Enter fullscreen mode Exit fullscreen mode

This is useful when working on a new feature while keeping the main branch stable.


8. Push Branch to GitHub

git push -u origin feature/2025/01-basic-dev-setup
Enter fullscreen mode Exit fullscreen mode

This creates a remote branch and links it to your local one.


Summary Commands Cheat Sheet

Task Command
Initialize Git git init
Configure Git git config --local user.name "Your Name"
Add all files git add .
Commit changes git commit -m "message"
Create branch git checkout -b branch-name
Push branch git push -u origin branch-name
Create repo (CLI) gh repo create

Useful Tools


📽️ Bonus: Watch the Full Video Tutorial

🎥 Git & GitHub for Express Developers – Full Guide
🖥️ Subscribe to Techstack Space for more tutorials.


Final Thoughts

Now that you know how to set up and use Git and GitHub in your Express projects, you’re one step closer to becoming a professional full-stack developer.

If you found this useful, share it, and let me know your questions in the comments!


Support This Project

If you find value in this content, consider supporting Techstack Space:

☕ Buy Me a Coffee
🌐 Visit Our Website

Top comments (0)