Git Cheat Sheet 2026

The 30 highest-yield Git facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.

88 questions
120 min time limit
70.00% to pass
  1. What does the `git config --global core.pager` setting control? The pager program (like `less`) used to display long Git output
  2. Who is credited with the invention of Git? Linus Torvalds
  3. Which setting controls line-ending conversion when checking out and committing files on Windows? core.autocrlf
  4. How do you stage the deletion of a tracked file and prepare it for the next commit? git rm
  5. Which flag for `git clean` performs a dry run, showing what would be deleted without actually removing anything? --dry-run or -n
  6. What is the main advantage of `git rebase` over `git merge` for integrating changes? Rebase produces a cleaner, linear commit history without merge commits
  7. Which command applies a specific commit from another branch onto the current branch? git cherry-pick
  8. The git command ________is used to add tags to a commit. git tag [commitID]
  9. In June 2018, which company paid $7.5 billion for GitHub? Microsoft
  10. Which command lists all local and remote branches? git branch -a
  11. What is the purpose of `git gc` (garbage collection)? Cleans up unnecessary objects and optimizes the local repository's pack files
  12. Which of the following does not fall inside the scope of Git configuration? User
  13. Which file can you set up to prevent specific file types from ever being committed to the local Git repository? .gitignore
  14. What does `git config --global color.ui auto` enable? Colored output in all Git commands when the terminal supports color
  15. How do you clone only a specific branch from a remote repository? Both A and B are correct
  16. For dealing with Git, which of the following command line environments is used? Git Bash
  17. Which command displays all active Git configuration values and their sources? git config --list --show-origin
  18. What does the `ORIG_HEAD` reference point to in Git? The HEAD position before the last risky operation such as a merge, rebase, or reset
  19. What is the staging area (index) in Git? An intermediate area where changes are prepared before being committed
  20. What does `git log --since='2 weeks ago'` do? Shows only commits made in the last 2 weeks
  21. What is the `git reflog` used for? Recording every movement of HEAD and branch tips, including resets and rebases
  22. Which `git merge` option always creates a merge commit even if fast-forward is possible? --no-ff
  23. Which Git command shows the patch that corresponds to each commit? git log-p
  24. What does `git config --global alias.st status` accomplish? Sets `git st` as a shorthand for `git status`
  25. Which Git command undoes a commit by creating a new commit that reverses the changes? git revert
  26. What does `git clone --depth 1` do? Creates a shallow clone with only the most recent snapshot and no full history
  27. What does the three-dot syntax `git log main...feature` show? Commits reachable from either branch but not their common ancestor
  28. What does `git commit --allow-empty` do? Creates a commit even when there are no staged changes
  29. Which command initializes a new Git repository in the current directory? git init
  30. What is Git's `refspec` used for? A pattern that maps remote references to local references during fetch and push
Turn these facts into recall: