WeCodeAcademy

Git Command Reference

The Git commands covered in the course, with examples that run in the practice terminal.

25 of 25
CommandGroupDescription
git initSetupStarts a repository in the current folder.
git statusBasicsShows what has changed.
git addBasicsStages changes for the next commit.
git commit -mBasicsSaves staged changes with a message.
git commit -amBasicsStages tracked changes and commits.
git logHistoryShows the commit history.
git log --onelineHistoryShort history, one line per commit.
git diffHistoryShows unstaged changes.
git diff --stagedHistoryShows staged changes.
git branchBranchesLists or creates branches.
git branch -dBranchesDeletes a merged branch.
git checkoutBranchesSwitches branches.
git checkout -bBranchesCreates a branch and switches to it.
git switchBranchesSwitches branches (modern form).
git mergeBranchesBrings another branch into the current one.
git restoreUndoDiscards changes in a file.
git restore --stagedUndoUnstages a file.
git reset --softUndoUndoes commits, keeps changes staged.
git resetUndoUndoes commits, keeps changes unstaged.
git reset --hardUndoUndoes commits and discards changes.
git stashUndoShelves uncommitted changes.
git stash popUndoRestores the newest stash.
git stash listUndoLists stashes.
git remote addRemoteConnects a remote repository.
git pushRemoteSends commits to a remote.