Git Commands Cheatsheet
Master version control with essential Git command structures — from configuration to advanced stashing, merging, and interactive rebasing.
Initial Setup & Config
git config --global user.name "Name"
Configure global username for commit attributes.
git config --global user.name "John Doe"
git config --global user.email "email"
Configure global email address for credentials.
git config --global user.email "john@doe.com"
git init
Initialize a new local Git repository in the current directory.
git init my-app
Staging & Committing
git status
List modified, untracked, and staged files.
git status --short
git add [file]
Stage file changes for the next commit. Use `.` for all files.
git add index.php | git add .
git commit -m "msg"
Record staged snapshot to repository history.
git commit -m "feat: add user login"
Branches & Collaboration
git branch [name]
Create a new local branch at current commit.
git branch feature/auth
git checkout -b [name]
Create and immediately switch to the new branch.
git checkout -b feature/pay
git push [remote] [branch]
Upload local commits to the remote branch.
git push origin main
No matching syntax found
Verify your query spelling or try searching another keyword.