DEV Community

Jedidah Ondiso
Jedidah Ondiso

Posted on

Git and GitHub for Beginners: A Friendly Guide

_ Installing Git Bash_

Google Git Bash

Download the Windows installer

Run the installer with these recommended settings:

Select "Use Git from Git Bash only "
Choose "Use the OpenSSL library"
Select "Checkout Windows-style, commit Unix-style line endings"
Choose "Use MinTTY"
Leave other options as default

Connecting Git to Your GitHub Account

  1. Check git verson
    git --version

  2. Configure Your Identity

git config --global user.name " name"
git config --global user.email "email"

  1. Generate an SSH Key # Generate a new SSH key ssh-keygen -t ed25519 -C " email"

C:\Users\YOUR_USERNAME.ssh\id_ed25519.pub

Add SSH Key to GitHub

Go to your GitHub account
Go to settings then click SSH and GPG keys
Click "New SSH key"
Paste your key and give it a descriptive name
Click "Add SSH key"

Test Your Connection
ssh -T git@github.com

WHAT IS GIT AND WHY IS VERSION CONTROL IMPORTANT

Git is a free, open-source distributed version control system (DVCS) used by developers to track changes in source code and other files during software development. It allows multiple people to collaborate on the same project without overwriting each other's work and enables users to revert to previous versions if needed.

IMPORTANCE OF VERSION CONTROL
• Prevents losing work when mistakes happen.
• Makes collaboration smooth and organized.
• Helps track who made which changes and when.
• Encourages experimentation—you can try new ideas without fear of breaking the main project.

HOW TO PUSH CODE TO GITHUB
GitHub is a platform that hosts your Git repositories online. Pushing code means sending your local changes to GitHub so others (or future you) can access them.
Steps to push code:
. Initialize Git in your project (if not already):

    Bash
    git init
Enter fullscreen mode Exit fullscreen mode

. Add your files to Git’s staging area:

    Bash
    git add
Enter fullscreen mode Exit fullscreen mode

. Commit your changes with a message:

     Bash
     git commit -m "Initial commit"
Enter fullscreen mode Exit fullscreen mode

. Connect your project to GitHub:

    Bash
    git remote add origin      https://github.com/username/repository.git
Enter fullscreen mode Exit fullscreen mode

. Push your code:

    Bash
    git push -u origin main

      HOW TOP PULL CODE FROM GitHub
Enter fullscreen mode Exit fullscreen mode

Pulling means downloading the latest changes from GitHub to your local machine.
Steps to pull code:
. Make sure you’re inside your project folder.
. Run:
Bash
git pull origin main
This updates your local project with any new commits from GitHub.

HOW TO TRACK CHANGES USING GIT
Git makes it easy to see what’s happening in your project.
• Check the status of your files:
Bash
git status

• Shows which files are new, modified, or staged.
• View commit history:
Bash
git log
• Displays a list of commits with messages, authors, and timestamps.
• Compare changes before committing:
Bash
git diff
Shows the exact lines that were added or removed.

Top comments (0)