Back to Homepage

Git Cheat Sheet

Git is a distributed version control system that tracks changes in source code and helps teams collaborate effectively.

Repository Basics

git init
git clone <repo-url>

Staging & Commit

git add .
git commit -m \"message\"

Branches

git branch
git switch -c feature
git merge feature

Remote & Sync

git remote -v
git remote add origin <url>
git remote set-url origin <new-url>
git push origin main
git pull

History

git log --oneline --graph --decorate --all
git reset --hard HEAD~1
git revert <commit>