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