logo Back to Home

Article Information

Category: Full Stack Development | Career Insights

Updated: december 3, 2025

Reading Time:6 min

Mastering Git & GitHub: From Basics to Advanced Commands

Updated: december 3, 2025

Git is one of the most important tools for developers. It helps you track every change in your code, work with teammates, and manage your projects efficiently. In this post, weโ€™ll learn everything about Git and GitHub โ€” from basic commands to a few advanced tricks that will make your workflow faster and more professional.

๐Ÿš€ What is Git?

Git is an open-source version control system that tracks changes in your source code. It helps developers maintain project history, collaborate effectively, and roll back to previous versions when needed.

โ˜๏ธ What is GitHub?

GitHub is a cloud-based platform that hosts your Git repositories online. It allows you to store your code, collaborate with teammates, review pull requests, and contribute to open-source projects easily.

In short:
Git = Tool for version control (local)
GitHub = Platform to host and collaborate on Git repositories (online)

โš™๏ธ Step 1: Setup Git

git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
      

These commands identify your commits with your name and email.

๐Ÿ“‚ Step 2: Initialize a Repository

git init

This command initializes a new Git repository in your project folder.

๐Ÿงฉ Step 3: Add Files

git add .

Adds all files to the staging area, preparing them for commit.

๐Ÿ’พ Step 4: Commit Changes

git commit -m "Initial commit"

Commits your code changes with a message. Each commit is a snapshot of your project.

๐Ÿ”— Step 5: Connect with GitHub

git remote add origin https://github.com/username/repository.git

Links your local Git project with a GitHub repository.

โฌ†๏ธ Step 6: Push to GitHub

git push -u origin main

Uploads your commits from local to GitHub.

โฌ‡๏ธ Step 7: Pull Changes

git pull origin main

Fetches and merges the latest changes from the GitHub repository.

๐ŸŒฟ Step 8: Branch Management

git branch feature-login
git checkout feature-login
      

Create and switch to new branches for developing features safely.

๐Ÿงน Step 9: Delete Branch

git branch -d feature-login

๐Ÿ” Step 10: Check Status

git status

๐Ÿ•ฐ๏ธ Step 11: View Commit History

git log --oneline

๐Ÿงฐ Extra Useful Git Commands

Command Description
git clone <url>Clone a GitHub repository
git diffShow file changes before commit
git stashTemporarily save uncommitted work
git revert <commit-id>Undo a specific commit
git reset --hard <commit-id>Reset repo to a previous state
git tag v1.0Create a version tag
git fetchGet remote changes without merging

๐Ÿงญ Example Workflow

git init
git add .
git commit -m "Initial commit"
git branch feature-login
git checkout feature-login
git add .
git commit -m "Added login feature"
git checkout main
git merge feature-login
git push origin main
      

๐Ÿ Conclusion

Git and GitHub are essential tools for modern developers. Once you understand the flow of adding, committing, and pushing code, you'll be able to manage projects confidently and collaborate efficiently with teams across the world.