Unit 2: Version Control & Source Code Management - Practice Quiz
1 What is the primary purpose of a version control system (VCS)?
2 Which of the following is a key benefit of using version control in software teams?
3 In Git, what is a repository?
4 Which hidden folder does Git create to store repository metadata?
.git
.vcs
.svn
.repo
5 Which command creates a new empty Git repository in the current directory?
git create
git init
git start
git new
6
What does the git add command do?
7 Which command uploads your local commits to a remote repository?
git init
git push
git pull
git add
8
What does the git pull command do?
9 What does a Git commit represent?
10 Which command is used to record staged changes with a message?
git store -m "message"
git commit -m "message"
git save -m "message"
git record -m "message"
11 What is a branch in Git?
12 Which command creates a new branch and switches to it in one step?
git move feature
git branch --switch feature
git new-branch feature
git checkout -b feature
13 What does merging accomplish in Git?
14 What is a Git tag commonly used for?
15
What is the main purpose of git rebase?
16
What does git stash do?
17 In the Feature Branch Workflow, where is new work typically developed?
.git folder manually
18 In GitHub Flow, what is typically opened to propose merging a branch into main?
19 When does a merge conflict typically occur in Git?
20 On GitHub, what are Issues primarily used for?
.git folder
21 A team of five developers is working on the same codebase without any version control system. Which problem are they most likely to encounter first?
22
You run git init inside an existing project folder. What is created as a result?
init pointing to the first commit
.git directory that stores repository metadata and history
23
After editing app.js, you run git commit -m "fix" but Git reports nothing to commit. What did you most likely forget?
git init again in the folder
git add app.js
24 Your local branch is behind the remote. Which command updates your local branch by fetching and integrating remote changes in one step?
git add
git commit
git push
git pull
25 What does the SHA-1 hash associated with a Git commit primarily represent?
26 You committed with the wrong message and have not pushed yet. Which command lets you correct only the message of the most recent commit?
git checkout HEAD~1
git commit --amend
git reset --hard HEAD
git revert HEAD
27
Which single command creates a new branch called feature and switches to it immediately?
git merge feature
git checkout -b feature
git branch feature
git switch feature
28 In Git, what does a branch fundamentally point to?
29
You merge feature into main, and main had no new commits since feature diverged. What type of merge does Git perform by default?
30 When Git creates a merge commit during a three-way merge, how many parent commits does that merge commit have?
31
Your team wants to mark commit v1.0 with a tag that stores the tagger name, date, and a message. Which command creates such an annotated tag?
git commit -t v1.0
git tag -a v1.0 -m "release 1.0"
git branch v1.0
git tag v1.0
32
What is the primary effect of running git rebase main while on your feature branch?
main, creating a linear history
main
feature branch after copying it to main
main into feature and creates a merge commit
33 Why is it generally discouraged to rebase commits that have already been pushed to a shared remote branch?
34 You have uncommitted changes but must quickly switch branches to fix a bug. Which command temporarily saves your work and cleans the working directory?
git reset
git commit
git clean
git stash
35 After stashing changes, which command reapplies the most recent stash and removes it from the stash list?
git stash drop
git stash pop
git stash list
git stash apply
36
In GitHub Flow, what is the recommended way to introduce a new feature into the main branch?
main and push immediately
develop branch parallel to main
main
main before every single commit
37 In the Feature Branch Workflow, what is the main purpose of keeping each feature on its own branch?
main always stays stable and deployable
38
While merging, Git inserts markers like <<<<<<<, =======, and >>>>>>> into a file. What must you do to complete the merge?
git merge --abort and ignore the conflict
39 On GitHub, which feature is best suited for tracking a reported bug and discussing how to fix it before any code is written?
40
In a GitHub pull request, what does linking it to an issue with a keyword like Closes #42 accomplish?
41
You run git init in a directory that is already inside an existing Git repository's working tree (a subfolder). What is the actual effect?
.git directory into the subfolder
42
A commit C has SHA abc123. You amend it with git commit --amend without changing anything except the author date. Which statement is true about the resulting commit?
abc123 since the file contents (tree) did not change
43
You rebase your feature branch onto main with git rebase main. Midway a conflict appears. After editing files and running git add, which command correctly continues the rebase?
git rebase --continue
git rebase --resume
git commit followed by git rebase --next
git merge --continue
44
Branch feature and main have diverged. You run git merge feature on main and Git performs a fast-forward. What must have been true?
feature's version
main had no commits that were not already reachable from feature, so main's tip is an ancestor of feature
feature and main shared no common ancestor at all
45
You have staged changes to a.txt and unstaged changes to b.txt. You run git stash push, then later git stash pop. By default, what is the state of the staging area after popping?
b.txt is restored because staged changes are never stashed by default
a.txt and b.txt changes return as unstaged; the original staged/unstaged distinction is lost unless --index was used
a.txt is restored as staged and b.txt as unstaged, exactly reproducing the pre-stash state
46 What is the key structural difference between a lightweight tag and an annotated tag in Git?
47
During a conflict, you see markers <<<<<<< HEAD, =======, and >>>>>>> feature. Which section sits between <<<<<<< HEAD and =======?
feature branch
48 Why is rebasing a branch that has already been pushed and pulled by collaborators considered dangerous?
49 In GitHub Flow, which sequence best reflects the intended workflow?
main, then create release and develop branches for stabilization before deploying
develop, merge to a release branch, then cherry-pick hotfixes back to main
main, commit work, open a pull request, discuss/review, deploy or test, then merge to main
main, create a long-lived integration branch, and merge features only during scheduled release windows
50
You create a branch with git branch feature but keep committing. Later you notice your new commits landed on main instead of feature. Why?
git branch feature only creates the branch; it does not switch to it, so HEAD stayed on main
git branch feature created a detached HEAD, so commits went nowhere addressable
-b are read-only until explicitly unlocked
51 What does the term "bare repository" refer to in Git, and why is it used for remotes?
.git folder is encrypted so contributors cannot read commit history directly
52
git pull is conceptually equivalent to which combination of operations by default?
git clone of the remote into a temporary directory followed by a copy
git push in reverse, downloading only the working directory files
git fetch followed by git rebase onto the upstream branch
git fetch followed by git merge of the tracked upstream branch into the current branch
53 What distinguishes a "recursive" (or "ort") merge from an "octopus" merge in Git?
54 In a GitHub pull request description, you write "Closes #42". What happens when the PR is merged into the default branch?
55
By default, git stash does NOT stash which category of files?
-u or -a is specified)
56 In the Feature Branch Workflow, why should feature branches be kept short-lived and frequently synced with the integration branch?
57
During an interactive rebase (git rebase -i), you want to combine a commit into the previous one while discarding the combined commit's message. Which action word should you use?
fixup
edit
reword
squash
58 You accidentally committed a large secret file, then made 5 more commits. To completely remove that file from all of history (not just the latest commit), which is the appropriate approach?
git rm --cached secret and commit; this retroactively deletes it from all previous commits
git filter-repo (or BFG) to purge the file from every commit, then force-push and rotate the secret
git revert on the offending commit to erase the file from history
.gitignore, which removes it from existing commits automatically
59 Which scenario most directly demonstrates a capability that distributed version control (like Git) provides but a purely centralized system (like classic CVS/SVN) does not?
60
After a botched conflict resolution during git merge, you want to abandon the merge and return the working tree to the exact state before you started. Which command does this?
git checkout --theirs .
git reset --soft HEAD
git merge --abort
git merge --continue
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →