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:
- VSCode.dev – Web-based VSCode
-
GitHub.dev – Open any GitHub repo in browser with
.dev
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 opengithub.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
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"
To confirm config:
git config --list
5. Stage and Commit Your Changes
Add all files:
git add .
Commit them:
git commit -m "Initial commit"
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
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
7. Create and Switch to a New Branch
git checkout -b feature/branch-name
Example:
git checkout -b feature/2025/01-basic-dev-setup
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
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:
Top comments (0)