Unit 2: Version Control & Source Code Management - Practice Quiz

INT331 — Fundamentals Of Devops 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is the primary purpose of a version control system (VCS)?

Why Version Control? Easy
A. To design database schemas visually
B. To host web applications on servers
C. To compile source code into binaries
D. To track and manage changes to code over time

2 Which of the following is a key benefit of using version control in software teams?

Why Version Control? Easy
A. Automatically writing all the code
B. Enabling multiple developers to collaborate safely
C. Replacing the operating system kernel
D. Removing the need for testing entirely

3 In Git, what is a repository?

Git Repositories Easy
A. A remote build server
B. A single line of source code
C. A type of merge conflict
D. A storage location that holds project files and their history

4 Which hidden folder does Git create to store repository metadata?

Git Repositories Easy
A. .git
B. .vcs
C. .svn
D. .repo

5 Which command creates a new empty Git repository in the current directory?

Git Cmd/Bash: Git basic operations (add, init, push, pull) Easy
A. git create
B. git init
C. git start
D. git new

6 What does the git add command do?

Git Cmd/Bash: Git basic operations (add, init, push, pull) Easy
A. Deletes files from the repository
B. Stages changes for the next commit
C. Uploads commits to a remote server
D. Creates a new branch

7 Which command uploads your local commits to a remote repository?

Git Cmd/Bash: Git basic operations (add, init, push, pull) Easy
A. git init
B. git push
C. git pull
D. git add

8 What does the git pull command do?

Git Cmd/Bash: Git basic operations (add, init, push, pull) Easy
A. Lists all branches
B. Removes untracked files locally
C. Creates a snapshot commit
D. Fetches and merges changes from a remote repository

9 What does a Git commit represent?

Commits Easy
A. A saved snapshot of staged changes at a point in time
B. A live connection to a remote server
C. A deleted branch reference
D. A list of installed dependencies

10 Which command is used to record staged changes with a message?

Commits Easy
A. git store -m "message"
B. git commit -m "message"
C. git save -m "message"
D. git record -m "message"

11 What is a branch in Git?

Branching Easy
A. A compressed backup file
B. A merge conflict marker
C. A copy of the remote server hardware
D. An independent line of development within a repository

12 Which command creates a new branch and switches to it in one step?

Branching Easy
A. git move feature
B. git branch --switch feature
C. git new-branch feature
D. git checkout -b feature

13 What does merging accomplish in Git?

Merging Easy
A. Reverts all commits to zero
B. Renames the repository
C. Combines changes from one branch into another
D. Deletes the current branch permanently

14 What is a Git tag commonly used for?

tagging Easy
A. Connecting to a remote repository
B. Storing uncommitted work temporarily
C. Resolving merge conflicts automatically
D. Marking specific points in history such as release versions

15 What is the main purpose of git rebase?

rebasing Easy
A. To reapply commits on top of another base for a linear history
B. To delete the remote repository
C. To stage all changed files
D. To create a new blank branch

16 What does git stash do?

stashing Easy
A. Creates a release tag
B. Temporarily saves uncommitted changes for later use
C. Pushes changes to the remote
D. Permanently deletes all local changes

17 In the Feature Branch Workflow, where is new work typically developed?

Git Remote Workflows: GitHub Flow, Feature Branch Workflow Easy
A. On a dedicated branch separate from the main branch
B. Inside the .git folder manually
C. Only in the remote's default branch
D. Directly on the production server

18 In GitHub Flow, what is typically opened to propose merging a branch into main?

Git Remote Workflows: GitHub Flow, Feature Branch Workflow Easy
A. A local tag
B. A stash entry
C. A pull request
D. A merge conflict

19 When does a merge conflict typically occur in Git?

Resolving Merge Conflicts Easy
A. When a commit message is too long
B. When a branch is created for the first time
C. When a repository is initialized
D. When two branches change the same lines of a file differently

20 On GitHub, what are Issues primarily used for?

GitHub: Issues, Pull Requests, Discussions Easy
A. Configuring the local .git folder
B. Compiling source code
C. Storing binary release files
D. Tracking bugs, tasks, and feature requests

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?

Why Version Control? Medium
A. Automatic deployment to production servers
B. Faster compilation of the shared code
C. Reduced disk space usage across machines
D. Overwriting each other's changes when copying files manually

22 You run git init inside an existing project folder. What is created as a result?

Git Repositories Medium
A. A new branch named init pointing to the first commit
B. A compressed backup of all files in the folder
C. A remote repository on GitHub linked to the folder
D. A hidden .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 Cmd/Bash: Git basic operations (add, init, push, pull) Medium
A. To pull the latest changes from the remote
B. To run git init again in the folder
C. To create a new branch before committing
D. To stage the file with 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 Cmd/Bash: Git basic operations (add, init, push, pull) Medium
A. git add
B. git commit
C. git push
D. git pull

25 What does the SHA-1 hash associated with a Git commit primarily represent?

Commits Medium
A. The author's encrypted password for the repository
B. A unique identifier derived from the commit's content and metadata
C. The sequential number of the commit on the branch
D. The timestamp of the commit in Unix epoch format

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?

Commits Medium
A. git checkout HEAD~1
B. git commit --amend
C. git reset --hard HEAD
D. git revert HEAD

27 Which single command creates a new branch called feature and switches to it immediately?

Branching Medium
A. git merge feature
B. git checkout -b feature
C. git branch feature
D. git switch feature

28 In Git, what does a branch fundamentally point to?

Branching Medium
A. A movable reference to a specific commit
B. A full copy of all files in the project
C. A snapshot of the staging area only
D. A remote server hosting the code

29 You merge feature into main, and main had no new commits since feature diverged. What type of merge does Git perform by default?

Merging Medium
A. A three-way recursive merge
B. An octopus merge
C. A squash merge
D. A fast-forward merge

30 When Git creates a merge commit during a three-way merge, how many parent commits does that merge commit have?

Merging Medium
A. Zero
B. One
C. Three
D. Two

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?

tagging Medium
A. git commit -t v1.0
B. git tag -a v1.0 -m "release 1.0"
C. git branch v1.0
D. git tag v1.0

32 What is the primary effect of running git rebase main while on your feature branch?

rebasing Medium
A. Replays your feature commits on top of the latest main, creating a linear history
B. Pushes your feature commits directly to the remote main
C. Deletes the feature branch after copying it to main
D. Merges 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?

rebasing Medium
A. It rewrites commit history, causing divergence for collaborators
B. It converts the branch into a tag
C. It permanently deletes the remote repository
D. It automatically resolves all conflicts incorrectly

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?

stashing Medium
A. git reset
B. git commit
C. git clean
D. git stash

35 After stashing changes, which command reapplies the most recent stash and removes it from the stash list?

stashing Medium
A. git stash drop
B. git stash pop
C. git stash list
D. git stash apply

36 In GitHub Flow, what is the recommended way to introduce a new feature into the main branch?

Git Remote Workflows: GitHub Flow Medium
A. Commit directly to main and push immediately
B. Create a long-lived develop branch parallel to main
C. Create a branch, open a pull request, review, then merge into main
D. Tag main before every single commit

37 In the Feature Branch Workflow, what is the main purpose of keeping each feature on its own branch?

Feature Branch Workflow Medium
A. To increase the number of commit hashes generated
B. To store backups of deleted files
C. To avoid ever needing to merge code
D. To isolate work so 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?

Resolving Merge Conflicts Medium
A. Run git merge --abort and ignore the conflict
B. Push the file with the markers intact to the remote
C. Delete the entire file so Git regenerates it
D. Edit the file to keep the desired content, remove the markers, then stage and commit

39 On GitHub, which feature is best suited for tracking a reported bug and discussing how to fix it before any code is written?

GitHub: Issues Medium
A. A Stash
B. A Pull Request
C. An Issue
D. A Tag

40 In a GitHub pull request, what does linking it to an issue with a keyword like Closes #42 accomplish?

Pull Requests Medium
A. Deletes issue #42 immediately when the PR is opened
B. Renames the branch to match issue #42
C. Automatically closes issue #42 when the pull request is merged
D. Prevents the pull request from ever being merged

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 Cmd/Bash: Git basic operations (add, init, push, pull) Hard
A. It automatically converts the subfolder into a Git submodule of the parent repository
B. It reinitializes the parent repository and moves its .git directory into the subfolder
C. It fails with a fatal error because nesting repositories is prohibited by Git
D. It creates a new nested repository in the subfolder, and files there are now tracked by the inner repo, effectively shadowing the outer repository for that path unless carefully managed

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?

Commits Hard
A. It fails because amending requires at least one staged content change
B. It produces a new commit with a different SHA, because the SHA is a hash over content including metadata such as author/committer info and timestamps
C. It updates only the committer field but reuses the original object, leaving the SHA unchanged
D. It keeps the same SHA 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?

rebasing Hard
A. git rebase --continue
B. git rebase --resume
C. git commit followed by git rebase --next
D. 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?

Merging Hard
A. There were textual conflicts that Git auto-resolved by choosing feature's version
B. A merge commit with two parents was created to preserve both histories
C. main had no commits that were not already reachable from feature, so main's tip is an ancestor of feature
D. 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?

stashing Hard
A. Only b.txt is restored because staged changes are never stashed by default
B. Both a.txt and b.txt changes return as unstaged; the original staged/unstaged distinction is lost unless --index was used
C. Both files are restored and automatically re-staged for you
D. 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?

tagging Hard
A. An annotated tag cannot be pushed to a remote, while a lightweight tag can
B. A lightweight tag is just a named pointer to a commit, whereas an annotated tag is a full Git object storing tagger name, date, message, and optional GPG signature, referencing the commit it points to
C. A lightweight tag stores the full commit history snapshot, while an annotated tag only stores a pointer
D. A lightweight tag can be signed but an annotated tag cannot

47 During a conflict, you see markers <<<<<<< HEAD, =======, and >>>>>>> feature. Which section sits between <<<<<<< HEAD and =======?

Resolving Merge Conflicts Hard
A. An auto-generated merge suggestion produced by Git
B. The content from your current branch (HEAD)
C. The content from the incoming feature branch
D. The nearest common ancestor's version of the content

48 Why is rebasing a branch that has already been pushed and pulled by collaborators considered dangerous?

rebasing Hard
A. Rebasing silently discards all commits that others have added
B. Rebasing rewrites commit history creating new SHAs, so collaborators' local branches diverge from the rewritten remote, causing duplicated commits and painful conflicts on their next pull
C. Rebasing corrupts the object database and cannot be reversed by any means
D. Rebasing deletes the remote branch entirely, forcing everyone to re-clone

49 In GitHub Flow, which sequence best reflects the intended workflow?

Git Remote Workflows: GitHub Flow Hard
A. Commit directly to main, then create release and develop branches for stabilization before deploying
B. Branch from develop, merge to a release branch, then cherry-pick hotfixes back to main
C. Create a branch from main, commit work, open a pull request, discuss/review, deploy or test, then merge to main
D. Tag 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?

Branching Hard
A. The new branch pointer was created but automatically deleted because it had no commits
B. git branch feature only creates the branch; it does not switch to it, so HEAD stayed on main
C. git branch feature created a detached HEAD, so commits went nowhere addressable
D. Branches created without -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 Repositories Hard
A. A repository with no branches, used only to store tags and releases
B. A repository without a working tree, containing only the version-control data, so pushes cannot conflict with checked-out files, making it ideal as a shared central remote
C. A repository stripped of all history except the latest commit to save space on servers
D. A repository whose .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 Cmd/Bash: Git basic operations (add, init, push, pull) Hard
A. git clone of the remote into a temporary directory followed by a copy
B. git push in reverse, downloading only the working directory files
C. git fetch followed by git rebase onto the upstream branch
D. 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?

Merging Hard
A. Recursive/ort merges two branches and can resolve criss-cross histories, while octopus merges three or more branches in a single commit but refuses conflicting merges
B. Recursive merges cannot produce a merge commit, unlike octopus merges
C. Recursive merges are always fast-forward, while octopus merges always create conflicts
D. Octopus merges only two branches but retries recursively until conflicts vanish

54 In a GitHub pull request description, you write "Closes #42". What happens when the PR is merged into the default branch?

GitHub: Issues, Pull Requests, Discussions Hard
A. The PR is blocked until issue #42 is manually closed first
B. A new issue #42 is created as a follow-up task
C. Issue #42 is automatically closed and linked to the merging commit
D. Issue #42 is deleted permanently from the repository

55 By default, git stash does NOT stash which category of files?

stashing Hard
A. Untracked and ignored files (unless -u or -a is specified)
B. Files with unstaged modifications in the working tree
C. Files that were renamed since the last commit
D. Files that have staged modifications

56 In the Feature Branch Workflow, why should feature branches be kept short-lived and frequently synced with the integration branch?

Git Remote Workflows: Feature Branch Workflow Hard
A. Frequent syncing is required because otherwise commits lose their SHAs over time
B. Long-lived branches accumulate divergence, increasing the size and difficulty of merge conflicts and delaying integration feedback
C. Short-lived branches are the only ones that can be protected with branch rules
D. Git physically cannot store branches older than a certain age and will delete them

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?

rebasing Hard
A. fixup
B. edit
C. reword
D. 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?

Commits Hard
A. Run git rm --cached secret and commit; this retroactively deletes it from all previous commits
B. Use a history-rewriting tool such as git filter-repo (or BFG) to purge the file from every commit, then force-push and rotate the secret
C. Use git revert on the offending commit to erase the file from history
D. Add the file to .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?

Why Version Control? Hard
A. A developer offline on a plane commits repeatedly, browses full history, and creates branches, all without any server connection
B. File permissions are automatically synchronized across every contributor's machine
C. The system guarantees that no commit can ever be lost under any circumstance
D. Two developers editing the same file are prevented from ever creating a conflict

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?

Resolving Merge Conflicts Hard
A. git checkout --theirs .
B. git reset --soft HEAD
C. git merge --abort
D. git merge --continue