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:
Was this helpful?