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
π¦ Windows (Git Bash)
- Download Git from https://git-scm.com/install/windows
- Run installer with default settings\
- Verify:
git --version
π€ Part 2 --- Configure Git (Name + Email)
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --list
π 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
Windows (Git Bash)
Same commands as Linux.
π Part 4 --- Add the Key to GitHub
- Copy output from:
<!-- -->
cat ~/.ssh/id_ed25519.pub
- GitHub β Settings β SSH and GPG keys β New SSH key\
- Paste and save
π§ͺ Part 5 --- Test the Connection
ssh -T git@github.com
π¦ 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"
π Part 7 --- Push to GitHub
git remote add origin git@github.com:USERNAME/REPO.git
git branch -M main
git push -u origin main
π Final Thoughts
With Git + SSH configured, pushing to GitHub becomes effortless and
secure.
Top comments (0)