Basic Commands
git initInitialize a new Git repository
git clone <url>Clone a repository
git statusCheck status of working directory
git add <file>Stage a file
git add .Stage all changes
git commit -m "message"Commit staged changes
git logView commit history
git diffShow changes
Branching
git branchList branches
git branch <name>Create a new branch
git checkout <branch>Switch to branch
git checkout -b <branch>Create and switch to branch
git merge <branch>Merge branch into current
git branch -d <branch>Delete branch
Remote
git remote -vList remotes
git remote add <name> <url>Add remote
git push <remote> <branch>Push to remote
git pull <remote> <branch>Pull from remote
git fetchFetch from remote
Undo
git reset HEAD <file>Unstage file
git checkout -- <file>Discard changes
git revert <commit>Revert a commit
git reset --soft HEAD~1Undo last commit, keep changes
git reset --hard HEAD~1Undo last commit, discard changes