What does git do?

the distributed version control system.

▸ Explain your own git command →

git examples, explained

$ git commit -am 'fix bug'

  • gitthe distributed version control system
  • commitrecord staged changes as a new commit
  • -aautomatically stage every tracked, modified file
  • -muse the next argument as the commit message
  • fix bugvalue for -m

$ git checkout -b feature

  • gitthe distributed version control system
  • checkoutswitch branches or restore files
  • -bcreate and switch to a new branch
  • featurevalue for -b

$ git log --oneline --graph --all --decorate

  • gitthe distributed version control system
  • logshow the commit history
  • --onelineshow each commit on a single line
  • --graphdraw an ASCII graph of the branch structure
  • --alloperate on everything (all branches / all changes)
  • --decorateshow ref names (branches, tags) next to commits

git subcommands

clone — copy a repository to your machineinit — create a new empty repository hereadd — stage changes for the next commitcommit — record staged changes as a new commitstatus — show what is staged, modified and untrackedpush — upload your commits to a remotepull — fetch from a remote and merge into the current branchfetch — download objects and refs from a remote (no merge)checkout — switch branches or restore filesswitch — switch to another branchbranch — list, create or delete branchesmerge — join another branch's history into this onerebase — reapply your commits on top of another baselog — show the commit historydiff — show changes between commits, branches or the working treestash — shelve uncommitted changes for laterreset — move the current branch and optionally the index/working treerevert — make a new commit that undoes an earlier onetag — create, list or delete tagsremote — manage the set of tracked repositoriescherry — apply the change introduced by a specific commitrestore — restore working-tree files

git flags & options

-muse the next argument as the commit message
-aautomatically stage every tracked, modified file
-bcreate and switch to a new branch
-fforce the operation
-ddelete (e.g. a branch)
-Dforce-delete (e.g. an unmerged branch)
-ndry run / no-commit, depending on the subcommand
--amendreplace the previous commit instead of adding a new one
--forceforce the operation (e.g. push)
--force-with-leaseforce-push only if the remote hasn't moved since you fetched
--alloperate on everything (all branches / all changes)
--onelineshow each commit on a single line
--graphdraw an ASCII graph of the branch structure
--decorateshow ref names (branches, tags) next to commits
--continueresume the operation after resolving conflicts
--abortcancel the operation and restore the original state
--skipskip the current commit and continue
--interactiveinteractive — edit the list of commits before replaying them
--set-upstreamrecord this remote branch as the upstream for tracking
--no-verifyskip the pre-commit and commit-msg hooks
-Crun as if git was started in the given directory

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.