Starting my journey in Data Science, Analysis, and AI at LUXDevHQ felt like learning a new language while trying to build a house. One of the most important tools I’ve discovered along the way is Version Control.
In this guide, I’ll walk you through:
- Setting up Git Bash
- Connecting Git to GitHub
- Mastering essential push and pull commands
1. What Is Git and Why Does It Matter?
Git is a Version Control System (VCS). Think of it as a save-point system for your code.
Why is Git important?
- ⏪ Time Travel – If you break your code, you can roll back to a version that worked.
- 🤝 Collaboration – Multiple people can work on the same project without overwriting each other’s work.
- 🧪 Experimentation – You can create branches to try new features without affecting the main project.
2. Setting Up Your Environment
Step A: Install Git Bash
- Go to Git and download Git for your OS (I used Windows).
- Run the installer. > 💡 Pro tip: You can keep the default settings for most options.
- After installation, search for Git Bash in your applications. It looks like a terminal window.
Step B: Configure Your Identity
To let GitHub know who is uploading code, configure your global Git settings:
git config --global user.name "Your Name"
git config --global user.email your-email@example.com
3. Secure Your Connection: Setting Up SSH Keys
Using SSH is the professional standard. It’s more secure and saves you from typing your password every time you push code.
Step 1: Generate Your SSH Key
Open Git Bash and enter (replace with your GitHub email):
ssh-keygen -t ed25519 -C your_email@example.com
• File Location: Press Enter to use the default location.
• Passphrase: As a beginner, I left this empty for convenience.
Step 2: Add Key to the SSH Agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
Step 3: Add the Public Key to GitHub
- Copy the key:
cat ~/.ssh/id_ed25519.pub
Go to GitHub: Settings → SSH and GPG keys → New SSH Key.
Give it a name (e.g., "My Learning Laptop") and paste your key into the "Key" box.
Step 4: Test the Connection
Run:
ssh -T git@github.com
Success Check! If you see "Hi [YourUsername]! You've successfully authenticated", you are ready!
4. Navigating and Creating Your Project
Learning to navigate via Git Bash makes you much faster than using a mouse! Use these commands to create your first repository:
• Check Location: pwd (Print Working Directory).
• Go to Desktop: cd Desktop
• Create Folder: mkdir my-first-repo
• Enter Folder: cd my-first-repo
5. Tracking Changes (The Core Workflow)
Before sending code to GitHub, Git needs to "track" it locally. Run these inside your project folder:
- Initialize Git: git init (Starts tracking the folder).
- Check Status: git status (See what files Git notices).
- Add Files: git add . (Stages all changes to be saved).
- Commit: git commit -m "My first commit" (Creates the "save point").
6. Pushing Code to GitHub
Pushing sends your local save points to the cloud.
Step A: Create the Repository on GitHub.com
- Log into GitHub, click the + icon → New repository.
- Name it (e.g., my-first-project) and keep it Public.
- Important: Leave "Add a README" unchecked to avoid conflicts.
- Click Create repository.
Step B: Connect and Push
On the GitHub setup page, click SSH and copy the URL. Then run these commands one by one:
git remote add origin git@github.com:your-username/repo-name.git
git push -u origin main
7. Pulling Code from GitHub
If you work on a different computer, use Pull to download the latest updates from the cloud:
git pull origin main
📚 Resources to Keep Learning
• Official Git Documentation
• GitHub Skills: Interactive Courses
• Visualizing Git Commands (Game)
Top comments (0)