Quick Reference
Git & GitHub Professional
From your first commit to reflog. Everything you need to master Git like a pro.
๐ Core Workflow & Setup
Setup / InitInitializes a new Git repository.
git initClone projectCopies an existing repository from GitHub.
git clone <url>ConfigurationSets global username and email.
git config --global user.name "Name"Check statusShows modified files and the current branch.
git statusAdd filesStages changes for commit.
git add .Staging area (alternative)Synonym for git add.
git stage .Create commitSaves the current snapshot.
git commit -m "msg"UploadSends local commits to the remote server.
git pushDownloadFetches changes from the server and merges them.
git pullRemote infoUpdates info about remote changes without merging.
git fetch๐ฟ Branching, Merging & Tags
Create branchCreates a new branch.
git branch <name>Switch branchModern way to switch branches.
git switch <name>Checkout (legacy)Older command to switch branches or files.
git checkout <name>MergeMerges changes into the current branch.
git merge <branch>RebaseReplays your changes on top of another branch.
git rebase <branch>Set tagsMarks important points (releases) in history.
git tag -a v1.0Merge toolsLaunches a visual tool for conflict resolution.
git mergetool๐จ Fix Errors & Recovery
Amend last commitModifies the last commit message or adds files.
git commit --amendReset (soft)Undoes commit, keeps changes in staging.
git reset --soft HEAD~1Reset (hard)WARNING: Resets everything to the last commit.
git reset --hard HEADRestore fileUndoes changes to a file.
git restore <file>Undo changeCreates a new commit that undoes an old one.
git revert <commit>Delete untracked filesDeletes files not tracked by Git.
git clean -fd๐ History & Inspection
Show historyCompact list of all commits.
git log --onelineShow detailsShows changes of a specific commit.
git show <commit>Check differencesCompares changes between working directory and staging.
git diffFind culpritShows line by line who changed what and when.
git blame <file>Search codeEfficiently searches for text across the repository.
git grep "search"Reflog (safety net)Log of all HEAD movements (rescues lost commits).
git reflogStatisticsShows a summary of commits per author.
git shortlog -sn๐งโโ๏ธ Advanced Expert Tools
Binary search for bugsUses binary search to find which commit introduced a bug.
git bisectList filesShows all files currently tracked by Git.
git ls-filesCleanupOptimizes the repository and removes unnecessary objects.
git gcMove/rename fileMoves a file and tracks the change immediately.
git mv <old> <new>Delete fileDeletes a file from the working directory and index.
git rm <file>Graphical interfaceLaunches the integrated graphical interface of Git.
git gui๐ก
If you've really messed something up and can't find the commit anymore: git reflog is your ultimate lifesaver!