DEV Community

Cover image for A Beginner’s Guide to Git and GitHub: From Installation to Your First Push
Jason Ndalamia
Jason Ndalamia

Posted on

A Beginner’s Guide to Git and GitHub: From Installation to Your First Push

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

  1. Go to Git and download Git for your OS (I used Windows).
  2. Run the installer. > 💡 Pro tip: You can keep the default settings for most options.
  3. 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

• 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
Enter fullscreen mode Exit fullscreen mode

Step 3: Add the Public Key to GitHub

  1. Copy the key:
cat ~/.ssh/id_ed25519.pub 
Enter fullscreen mode Exit fullscreen mode
  1. Go to GitHub: Settings → SSH and GPG keys → New SSH Key.

  2. 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
Enter fullscreen mode Exit fullscreen mode

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:

  1. Initialize Git: git init (Starts tracking the folder).
  2. Check Status: git status (See what files Git notices).
  3. Add Files: git add . (Stages all changes to be saved).
  4. 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

  1. Log into GitHub, click the + icon → New repository.
  2. Name it (e.g., my-first-project) and keep it Public.
  3. Important: Leave "Add a README" unchecked to avoid conflicts.
  4. 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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

📚 Resources to Keep Learning

Official Git Documentation
GitHub Skills: Interactive Courses
Visualizing Git Commands (Game)

Conclusion: Congratulations! You've just set up a professional dev workflow. Git can be tricky at first, but keep practicing and it will become second nature. If you ran into any issues, drop a comment below and let's help each other out!

Top comments (0)