You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?
Commands
One page per command. What it does, when to use it, how risky it is.
Terminal basics
Set up
git --versionShows which Git version you have.Risk: Safegit configReads or changes Git settings.Risk: Safegit helpShows help for a command.Risk: Safe
Save your work
git initMakes a folder into a Git repo.Risk: Safegit statusShows what changed and what is in the box.Risk: Safegit addPuts changes in the box (staging area).Risk: Safegit commitSaves the box as a save point.Risk: Safegit rmDeletes a file and tells Git.Risk: Carefulgit mvRenames or moves a file.Risk: Safe
Look at history
git logLists your save points, newest first.Risk: Safegit showShows one commit and what it changed.Risk: Safegit diffShows the changed lines. Red removed, green added.Risk: Safegit branchLists branches. A star shows where you are.Risk: Safe
Undo things
git restorePuts a file back to a saved version.Risk: Can lose workgit resetMoves your branch back to an older commit.Risk: Carefulgit revertMakes a new commit that undoes an old one.Risk: Safegit switchMoves HEAD to a branch, or to a commit.Risk: Safegit checkoutThe older way to switch branches or visit commits.Risk: Carefulgit cleanDeletes untracked junk files.Risk: Can lose workgit reflogShows every place HEAD has been.Risk: Safegit filter-repoRewrites history, for example to wipe a file from every commit. A separate tool you install.Risk: Can lose work
Branches and merging
git branchMakes, renames or deletes a branch. A branch is a sticky note on a commit.Risk: Carefulgit switchMakes a new branch and moves you onto it.Risk: Safegit mergeJoins another branch's work into the branch you are on.Risk: Safegit stashPuts your unsaved changes in a drawer, so your folder is clean.Risk: Carefulgit rebaseReplays your commits on top of another branch. You get new commits.Risk: Carefulgit cherry-pickCopies one commit from somewhere else onto your branch.Risk: Safe
Work with GitHub
git remoteLists or saves remotes: short names for online copies of your project.Risk: Safegit pushSends your new commits to the remote, like GitHub.Risk: Carefulgit pushOverwrites the remote branch with yours. Other people's commits there can be lost.Risk: Can lose workgit cloneCopies a whole project, with all its history, to your computer.Risk: Safegit fetchDownloads news from the remote. Your own branches stay the same.Risk: Safegit pullFetches, then joins the new commits into your branch.Risk: Carefulgit tagPuts a name that never moves on a commit, like v1.0.Risk: Safe
GitHub tools
ghCopies a GitHub repo to your computer, like git clone.Risk: SafeghMakes your own copy (a fork) of a repo in your GitHub account.Risk: SafeghOpens a new issue on GitHub from your terminal.Risk: SafeghLists the open issues in this repo.Risk: SafeghOpens a pull request for your current branch.Risk: SafeghBrings a pull request's branch to your computer and switches to it.Risk: SafeghStarts a new Codespace: a computer in the cloud for a repo.Risk: Safe
Deep Git
git cat-fileShows one object from inside Git: a commit, tree, blob or tag.Risk: Safegit hash-objectPrints the id Git gives a file's content.Risk: Safegit ls-treeLists the files and folders inside one tree.Risk: Safegit rev-parseTurns a name like HEAD~2 or main into a full commit id.Risk: Safegit logFinds commits by what they changed, who made them, or their message.Risk: Safegit grepSearches the files Git tracks for a word or pattern.Risk: Safegit blameShows who last changed each line of a file, and in which commit.Risk: Safegit shortlogGroups the commits by author.Risk: Safegit bisectFinds the commit that broke something by halving the history.Risk: Carefulgit worktreeOpens a second working folder for the same repo.Risk: Carefulgit configMakes a short name for a Git command you type often.Risk: Safegit show-refLists your refs (branches and tags) with the commit id of each.Risk: Safegit pack-refsMoves many small ref files into one file, .git/packed-refs.Risk: Safegit gcTidies the repo: packs objects and throws away ones nothing can reach.Risk: Carefulgit maintenanceKeeps a repo fast with small tidy-up jobs, in the background.Risk: Safegit submoduleKeeps another repo inside yours, linked at one exact commit.Risk: Carefulgit sparse-checkoutShows only some folders of a big repo in your working folder.Risk: Safegit rerereRemembers how you fixed a conflict and replays the fix next time.Risk: Safegit range-diffCompares two versions of a branch, commit by commit.Risk: Safe