Master Git and use it like a pro in your projects
๐ Read the interactive book ยป
Report Bug
ยท
Request Feature
In professional development and large team projects, version control is a must. While Git is a powerful tool that enhances collaboration and productivity, its many features can sometimes feel overwhelming.
This guide is your go-to introduction to Git, covering both beginner and advanced commands. ๐ก Our goal is to help you feel confident when initializing a repo, managing updates, and resolving conflicts proving that Git isnโt as intimidating as it seems.
๐ You'll find a comprehensive cheat sheet with clear examples and illustrations to help you master Git with ease.
The course is an interactive, animated book. The easiest way to read it is in your browser:
npm install
npm run devThe book is built with Astro Starlight and
served at http://localhost:4321/git-primer/.
Every push to main builds the book and deploys it to GitHub Pages
automatically via the
deploy-book.yml workflow.
- Introduction to Git
- What is Git? Why use it?
- Difference between Git and GitHub
- Installing Git (Windows, macOS, Linux)
- Basic Git configuration (git config)
- Setting Up a Git Repository
- Initializing a repository (git init)
- Cloning a repository (git clone)
- Understanding the .git folder
- Basic Git Workflow
- Checking repository status (git status)
- Staging changes (git add)
- Committing changes (git commit)
- Viewing commit history (git log)
- Working with Branches
- What are branches? Why use them?
- Creating and switching branches (git branch, git checkout, git switch)
- Merging branches (git merge)
- Resolving merge conflicts
- Remote Repositories
- Connecting to a remote (git remote add)
- Pushing changes (git push)
- Fetching changes (git fetch)
- Pulling updates (git pull)
- Forking and contributing to open-source projects
- Undoing Changes & Resetting History
- Discarding local changes (git restore, git checkout)
- Unstaging files (git reset HEAD)
- Amending commits (git commit --amend)
- Reverting commits (git revert)
- Reset vs. Revert vs. Checkout
- Understanding Git Internals
- The Git object model (blobs, trees, commits)
- How Git stores changes (snapshots vs. diffs)
- Git references (HEAD, refs, tags)
- Advanced Git Commands
- Interactive rebasing (git rebase -i)
- Reflog and recovering lost commits (git reflog)
- Cherry-picking commits (git cherry-pick)
- Stashing work (git stash)
- Git Hooks & Automation
- Pre-commit hooks (.git/hooks/pre-commit)
- Post-commit and other hooks
- Automating workflows with Git
- Git Best Practices
- Writing good commit messages
- Keeping a clean commit history
- Git workflows (Git Flow, Trunk-based, GitHub Flow)
- Troubleshooting & Debugging Git Issues
- Fixing detached HEAD state
- Dealing with merge conflicts
- Resolving git push and git pull errors
- Diagnosing issues with git fsck and git gc
- Working with Submodules & Large Repositories
- Using submodules (git submodule)
- Handling large files with Git LFS
- Optimizing repository performance
- Using Git with Other Tools
- GitHub/GitLab/Bitbucket basics
- Integrating Git with CI/CD
- Using Git in VS Code and other IDEs
- Real-World Git Scenarios
- Collaborating in a team
- Handling hotfixes and release branches
- Recovering from mistakes
- Learning resources
- Practice sandboxes, exercises, and talks
This repository and all its content is under GNU General Public License v3.0.