Git Cheat Sheet
Git Cheat Sheet
git init
Initialize a new Git repository.
git clone <url>
Copy a remote repo to your computer.
git status
Check which files are staged/unstaged/untracked.
git add <file>
Stage a specific file for commit.
git add .
Stage all files for commit.
git commit -m "msg"
Commit staged changes with a message.
git log
View commit history.
git diff
View changes not yet staged.
git diff --staged
View staged changes.
git branch
List all branches.
git branch <name>
Create a new branch.
git checkout <name>
Switch to another branch.
git checkout -b <name>
Create and switch to a new branch.
git merge <branch>
Merge a branch into the current branch.
git pull
Fetch and merge changes from remote.
git push
Upload commits to remote.
git remote -v
List remote repositories.
git reset HEAD <file>
Unstage a file.
git reset --hard <commit>
Reset to a specific commit.
git stash
Temporarily save uncommitted changes.
git stash pop
Reapply the last stashed changes.