Master Git from the fundamentals to advanced workflows through structured lessons, practical examples, and real-world commands.
HomeFollow the topics in order to build a solid understanding of Git.
Understand what Git is and why developers use it.
Install Git and configure your development environment.
Learn git init, add, commit, status and log.
Create, switch and merge branches.
Push, pull, clone and collaborate using GitHub.
Explore stash, rebase, cherry-pick and more.
Before learning Git commands, it's important to understand what Git is and why developers use it.
Git is a distributed version control system that helps developers track changes in their source code. It allows multiple developers to work together efficiently while maintaining a complete history of every change made to a project.
Restore previous versions anytime.
Develop new features independently.
Multiple developers can work together.
Your complete project history is preserved.
Before using Git, you need to install it and configure your identity.
Download Git from the official website and install it on your operating system.
Download GitSet your username and email. These details will appear in every commit.
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Create a new project folder and initialize Git.
mkdir MyProject
cd MyProject
git init
View the current state of your project.
git status
Add files to the staging area.
git add index.html
git add .
git add style.css
Save your work permanently.
git commit -m "Initial Commit"
Learn how to inspect your repository, restore changes, remove files, and manage your project history.
Display all commits made in your repository.
git log
Useful for checking previous commits, commit IDs, authors, and dates.
Compare modified files with the last commit.
git diff
Discard local changes made to a file.
git restore index.html
Delete a file and stage the deletion.
git rm file.txt
Rename a tracked file.
git mv oldname.txt newname.txt
Unstage a file without deleting your work.
git reset index.html
Branches allow developers to build new features safely without affecting the main project.
git branch feature-login
Creates a new branch named feature-login.
git checkout feature-login
Move from the current branch to another branch.
git checkout -b feature-navbar
Creates a new branch and switches to it immediately.
git branch
git checkout main
git merge feature-login
Merge completed work into the main branch.
git branch -d feature-login
Learn how to connect your local Git repository with GitHub and collaborate online.
git clone https://github.com/username/project.git
Downloads an existing GitHub repository to your computer.
git remote add origin https://github.com/username/project.git
Links your local project to a remote GitHub repository.
git push -u origin main
Upload your commits to GitHub.
git pull origin main
Download and merge the latest changes from GitHub.
git fetch origin
Downloads new commits without merging them.
git remote -v
Displays all configured remote repositories.
Master powerful Git features used in professional software development.
git stash
Stores your uncommitted changes temporarily.
git stash pop
Restores the latest stashed changes.
git rebase main
Replays your branch commits on top of another branch for a cleaner history.
git cherry-pick commit_id
Apply a specific commit from another branch.
git tag v1.0
Mark an important release or version.
git revert commit_id
Undo a commit without rewriting project history.