Quick reference for the most common Git commands
Check Git version
git --versionSet your name
git config --global user.name "Your Name"Set your email
git config --global user.email "you@example.com"Create a new repository
git initCheck status of files
git statusAdd all files to staging
git add .Add specific file
git add <filename>Save changes with a message
git commit -m "message"View commit history
git logView compact history
git log --onelineList all branches
git branchCreate new branch
git branch <name>Switch to branch
git checkout <name>Create and switch to new branch
git checkout -b <name>Merge branch into current branch
git merge <branch>Delete branch
git branch -d <name>Download a repository
git clone <url>Connect local repo to GitHub
git remote add origin <url>Upload changes to GitHub
git push origin mainPush and set upstream
git push -u origin mainDownload latest changes
git pullPull from specific branch
git pull origin mainView remote repositories
git remote -vShow unstaged changes
git diffShow staged changes
git diff --stagedUnstage a file
git reset <file>Discard changes in file
git checkout -- <file>Temporarily save changes
git stashRestore stashed changes
git stash popfeat: New feature for users
git commit -m "feat: add user login page"fix: Bug fix
git commit -m "fix: resolve payment bug"docs: Documentation changes
git commit -m "docs: update README"style: Code formatting (no logic change)
git commit -m "style: format code"refactor: Code restructuring (no new features)
git commit -m "refactor: simplify auth logic"test: Adding or updating tests
git commit -m "test: add login tests"chore: Maintenance (configs, packages, etc.)
git commit -m "chore: update dependencies"perf: Performance improvements
git commit -m "perf: optimize image loading"Tip
Don't try to memorize all commands at once! Copy the ones you need and practice them regularly. They'll become natural with time.