A Newbie's Guide to Git (Git Bash)
Are you a newbie to Git like I once was? Don't worry! This guide will help you get started with Git using Git Bash on a Windows PC. We'll cover installation, configuration, connecting to GitHub, and some essential commands. By the end, you'll be ready to version control your projects confidently.
What is GitHub?
GitHub is a cloud-based platform where you can create, store, manage, and share your code. It allows collaboration with others, tracks changes, and hosts repositories (repos) for your projects. Think of it as a virtual storage for your code with superpowers for teamwork.
What is Git/Git Bash?
Git is a version control system that helps you track changes in your code over time. Git Bash is the command-line interface (CLI) that comes with Git on Windows, providing a Unix-like shell to run Git commands. It's your tool to interact with GitHub from your PC without needing a browser every time.
Fun Fact
Git uses cryptographic hashing (like SHA-1 or SHA-256) to uniquely identify each commit. This ensures your code's integrity and makes it tamper-proof!
What is a Commit?
A commit is like a snapshot of your project at a specific point. It's a permanent record of changes, including who made them and when. Once committed, you can always revert to that state if needed.
Setting Up Your GitHub Account
- Go to GitHub in your browser.
- Click "Sign up" and follow the prompts to create an account with your email.
- Verify your email and set up your profile: add a username, bio, and profile picture for a professional touch.
Once done, you're ready to connect your local Git to GitHub.
Installing Git/Git Bash on Windows
- Open your browser and search for "Git download" or go directly to git-scm.com.
- Select "Windows" as your OS.
- Download the installer (it's free!).
- Run the .exe file and follow the setup wizard. Accept defaults unless you know what you're changing.
- During installation, choose "Use Visual Studio Code as Git's default editor" if you have VS Code installed, it's beginner-friendly.
- Complete the installation; Git Bash should now be in your Start menu.
Here's what the download page looks like:

Official Git downloads page, click on Windows to get the installer.
After installation, search for "Git Bash" in your Start menu and open it. It should look something like this (though this image shows settings integration):

Integrating Git Bash into Windows Terminal for a better experience (optional).
Connecting Git/Git Bash to GitHub Using Commands
Now, let's configure Git and set up SSH for secure connection.
- Open Git Bash.
Check Git version:
git --version
(It should show something like git version 2.x.x)Set your username (replace with your GitHub username):
git config --global user.name "Your Username"
text4. Set your email (must match your GitHub email):
git config --global user.email "your.email@example.com"
text5. Verify configurations:
git config --list
text6. Generate an SSH key:
ssh-keygen -t ed25519 -C "your.email@example.com"
textPress Enter for defaults (no passphrase for beginners).

Running ssh-keygen in Git Bash-enter a passphrase or leave blank.
Start the SSH agent:
eval "$(ssh-agent -s)"
text8. Add your SSH key to the agent:
ssh-add ~/.ssh/id_ed25519
text9. Display your public key:
cat ~/.ssh/id_ed25519.pub
textCopy the output (starts with ssh-ed25519...).-
Go to GitHub: Settings > SSH and GPG keys > New SSH key.
- Title: Something like "My Windows PC".
- Paste the key and add it.

GitHub SSH keys page, paste your public key here.
- Test the connection: ssh -T git@github.com textIt should say: "Hi username! You've successfully authenticated..."
Congrats! Your Git Bash is now connected to GitHub.
Basic Git Commands and Concepts
Version Control with Git
Git tracks changes by taking snapshots (commits). It provides an audit trail: who changed what and when. You can revert to any previous version easily.
Push and Pull
-
Push: Upload your local changes to GitHub.
Example workflow:
git add . # Stage all changes
git commit -m "Your commit message" # Commit them
git push origin main # Push to the main branch
text- Pull: Download changes from GitHub to your local repo.
git pull origin main
text(Use --rebase if you want a linear history:
git pull --rebase origin main)
Tracking Code Changes
-
git status: Shows what's changed, staged, or untracked.

Git status showing uncommitted changes.
-
git diff: Views differences in unstaged changes. -
git diff --staged: Views staged changes. -
git log: Shows commit history. -
git log --oneline: Condensed history. -
git log -- filename: History for a specific file. -
git show commit-hash: Details of a specific commit.

Git log displaying recent commits with details.
Conclusion
You've now got the basics of Git and Git Bash on Windows! Practice by creating a repo on GitHub, cloning it locally (git clone repo-url), making changes, and pushing them back.
If you run into issues, common fixes include ensuring your email matches and regenerating SSH keys if needed. Drop a comment below with questions or feedback.
Top comments (0)