0% found this document useful (0 votes)
22 views3 pages

Git & GitHub Cheat Sheet

This Git & GitHub Cheat Sheet provides essential commands for setup, repository management, basic workflows, branching, undoing changes, and working with remote repositories. It includes commands for checking versions, configuring user details, staging and committing changes, and managing branches. Additionally, it offers tips for effective version control practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views3 pages

Git & GitHub Cheat Sheet

This Git & GitHub Cheat Sheet provides essential commands for setup, repository management, basic workflows, branching, undoing changes, and working with remote repositories. It includes commands for checking versions, configuring user details, staging and committing changes, and managing branches. Additionally, it offers tips for effective version control practices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

🧾Git & GitHub Cheat Sheet

📁 Setup Commands
Command Description

git --version Check installed Git version

git config --global user.name "Your Name" Set your Git username

git config --global user.email "[email protected]" Set your Git email

git config --list View current config

📂 Repository Commands
Command Description

git init Initialize a new local Git repo

git clone <repo-url> Clone an existing remote repo

📝 Basic Workflow
Command Description

git status Check current repo status

git add <file> Stage a specific file

git add . Stage all changes

git commit -m "message" Commit changes with a message

git push Push commits to remote

git pull Pull latest changes from remote

git log View commit history


🌿 Branching
Command Description

git branch List all branches

git branch <branch-name> Create a new branch

git checkout <branch-name> Switch to a branch

git checkout -b <branch> Create and switch to new branch

git merge <branch> Merge another branch into current

git branch -d <branch> Delete a branch (if merged)

🧠 Undo & Reset


Command Description

git reset <file> Unstage a file

git checkout -- <file> Discard local changes to file

git revert <commit> Undo a commit by creating a new one

git reset --hard <commit> Reset everything to a specific commit ⚠️

🔗 Remote Repositories

Command Description

git remote -v View remote repo URL(s)

git remote add origin <url> Add remote repo

git push -u origin main Push local to remote first time


🧰 Other Useful Commands
Command Description

git stash Temporarily save changes

git stash pop Apply latest stashed changes

git diff Show changes not yet staged

📌 Tips:
Always pull before you push.
Use meaningful commit messages.
Create feature branches for separate tasks.

You might also like