DEV Community

Cover image for Git and GitHub setup for Linux and Windows | Full Guide.
Bek Brace
Bek Brace

Posted on

Git and GitHub setup for Linux and Windows | Full Guide.

Every time I have a new machine, I need to configure a bunch of stuff, including Git, and I wanted to leave a manual for Linux and Windows users on how to properly connect Git on your machine with GitHub.
Hopefully,this will help.

Setting Up Git + SSH From Scratch on Linux (Debian/Ubuntu) and Windows (Git Bash) --- A Complete Beginner-Friendly Guide

Whether you're starting your coding journey or setting up a fresh
machine, configuring Git with SSH is essential. This guide covers a
clean setup on Linux (Debian-based) and Windows (Git Bash).

πŸ”§ Part 1 --- Install Git

🟦 Linux (Debian/Ubuntu)

sudo apt update
sudo apt install git
git --version
Enter fullscreen mode Exit fullscreen mode

🟦 Windows (Git Bash)

  1. Download Git from https://git-scm.com/install/windows
  2. Run installer with default settings\
  3. Verify:
git --version
Enter fullscreen mode Exit fullscreen mode

πŸ‘€ Part 2 --- Configure Git (Name + Email)

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

πŸ” Part 3 --- Generate an SSH Key

Linux

mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t ed25519 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

Windows (Git Bash)

Same commands as Linux.

πŸ”— Part 4 --- Add the Key to GitHub

  1. Copy output from:
<!-- -->
Enter fullscreen mode Exit fullscreen mode
cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode
  1. GitHub β†’ Settings β†’ SSH and GPG keys β†’ New SSH key\
  2. Paste and save

πŸ§ͺ Part 5 --- Test the Connection

ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ Part 6 --- Create Your First Repository

mkdir myproject
cd myproject
git init
echo "Hello Git" > readme.txt
git add readme.txt
git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

πŸš€ Part 7 --- Push to GitHub

git remote add origin git@github.com:USERNAME/REPO.git
git branch -M main
git push -u origin main
Enter fullscreen mode Exit fullscreen mode

πŸŽ‰ Final Thoughts

With Git + SSH configured, pushing to GitHub becomes effortless and
secure.

Top comments (0)