You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your quick reference to essential Git commands while developing!
🔧 Setup
Command
Description
git config --global user.name "Your Name"
Set your Git username
git config --global user.email "you@example.com"
Set your Git email
git config --global credential.helper store
Store GitHub password locally so you don’t enter it every time
git config --list
Check Git configuration
git --version
Show Git version
🛠️ Starting a Project
Command
Description
git init
Initialize a new Git repo
git clone <repo_url>
Clone a remote repo locally
git remote -v
Show remote URLs
📁 Staging & Committing
Command
Description
git status
See modified/added files
git add <file>
Stage a specific file
git add .
Stage all changes
git reset HEAD <file>
Unstage a file (keep changes)
git commit -m "message"
Commit staged changes with a message
git rm <file>
Remove a tracked file
git restore <file>
Discard changes to a file
git log
View commit history
git log
Press q to quit the git log
🔄 Working with Remotes
Command
Description
git remote add origin <url>
Link local repo to remote
git push -u origin master
Push first time with upstream tracking
git push -u origin main
Push first time with upstream tracking (for main branch)
git remote -v
Check remote
git push
Push changes to remote
git pull
Pull latest changes from remote
git pull origin <another_branch>
Pull changes from a specific branch on the remote without switching to it
git fetch
Fetch changes without merging
📝 Use git push -u origin main if your default branch is main (GitHub default since Oct 2020).
This sets the upstream so you can just run git push or git pull without specifying the branch.