← Back to Quiz Home
Leveling up! 🌟
You know the basics—now let's see if you can handle branching, merging, and stashing.
Instructions:
- These questions cover common daily workflows.
- Select the correct commands and concepts.
- Good luck!
Which command combines two branches while creating a new commit?
git merge joins two or more development histories together.
Which command temporarily saves your changes without committing them?
git stash temporarily shelves (or stashes) changes you've made to your working copy.
What is the difference between git fetch and git pull?
git fetch only downloads data, while git pull downloads and then merges the data.
Which command is used to discard changes in the working directory?
git restore restores working tree files. It can be used to discard uncommitted changes.
Which command modifies the most recent commit?
git commit --amend allows you to modify the last commit (e.g., fix the message or add forgotten files).
Which command shows the difference between the working directory and the staging area?
git diff (without arguments) shows changes not yet staged.
Which command shows the difference between the staged changes and the last commit?
git diff --staged (or --cached) shows what would be committed if you ran git commit.
Which command creates a new safe reverse commit to undo changes?
git revert creates a new commit that applies the inverse of the specified commit. Safe for public branches.
How do you force delete a branch that has not been merged?
git branch -D is a shortcut for --delete --force.
Which command removes untracked files from the working directory?
git clean removes untracked files from the working tree.
Which command applies a stash and drops it from the stash list?
git stash pop applies the top stash and removes it from the stack.
Which command is used to see who changed a specific line in a file?
git blame annotates each line in the given file with information from the revision which last modified the line.
What is a "fast-forward" merge?
A fast-forward merge happens when the target branch contains all the history of the current branch, so Git just moves the pointer.
How do you stop tracking a file but keep it in your local storage?
git rm --cached removes the file from the index (staging) but leaves the working file alone.
Which command adds a new remote repository?
git remote add adds a new remote shorthand.
Which command displays a linear graph of commits?
git log --graph draws a text-based graphical representation of the commit history.
What does git reset --soft HEAD~1 do?
--soft resets HEAD but keeps the index (staging area) intact.
What is the default behavior of git pull if not configured otherwise?
By default, pull performs a merge (unless configured to rebase).
How do you list all tags?
git tag (with no arguments) lists existing tags.
Which command helps you switch to a specific commit (entering detached HEAD state)?
git checkout allows checkout of specific commits, Detaching HEAD. Note: git switch --detach also works but checkout is classic.
Quiz Progress
0 / 0 questions answered
(0%)
0 correct
Quiz Complete!
0%
📚 Study Guides
📬 Weekly DevOps, Cloud & Gen AI quizzes & guides