Git Commands Cheat Sheet
The essential commands you need to master version control.
Setup & Config
git initInitialize a new Git repository in the current directory.
git clone [url]Clone a repository from a remote source (like GitHub).
git config --global user.name '[name]'Set the name attached to your commits.
git config --global user.email '[email]'Set the email attached to your commits.
Basic Snapshotting
git statusShow modified files in working directory, staged for your next commit.
git add [file]Add a file as it looks now to your next commit (stage it).
git add .Add all changed files to the staging area.
git commit -m '[message]'Commit your staged content as a new snapshot.
Branching & Merging
git branchList your branches. a * will appear next to the currently active branch.
git branch [branch-name]Create a new branch at the current commit.
git checkout [branch-name]Switch to another branch and check it out into your working directory.
git merge [branch]Merge the specified branch's history into the current one.
Sharing & Updating
git remote add origin [url]Connect your local repo to a remote server.
git push origin [branch]Upload local branch commits to the remote repository.
git pullFetch and merge changes on the remote server to your working directory.
git logShow the commit history for the currently active branch.