Unit 4: Advanced Git - Practice Quiz

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

1 Which command allows you to view the changes between the working directory and the staging area?

A. git diff
B. git status
C. git diff --cached
D. git diff HEAD

2 In the context of Git objects, what constitutes the unique identifier for a commit?

A. A user-defined tag
B. A 40-character SHA-1 hash
C. The timestamp of the commit
D. A sequential integer ID

3 Which command is used to create a new branch and switch to it immediately in a single step?

A. git checkout -b <name>
B. git checkout <name>
C. git branch <name>
D. git switch <name>

4 When performing a git merge, what is a 'Fast-forward' merge?

A. A merge where the current branch tip is simply moved up to the target branch tip
B. A merge that creates a new commit object
C. A merge used only for remote repositories
D. A merge that resolves conflicts automatically

5 Which command displays the commit history along with the diffs introduced by each commit?

A. git show
B. git log -p
C. git log --stat
D. git log --oneline

6 What is the primary difference between git merge and git rebase?

A. Merge preserves history structure; rebase rewrites history to be linear
B. Merge rewrites history; rebase preserves history
C. There is no functional difference
D. Merge is used for local branches; rebase is for remote branches

7 How do you view changes that have been staged but not yet committed?

A. git log --staged
B. git diff --staged
C. git diff
D. git show

8 Which command allows you to temporarily save your changes in the working directory without committing them?

A. git checkout .
B. git stash
C. git commit --amend
D. git reset --soft

9 What is the result of running git stash pop?

A. It applies the most recent stash and removes it from the stack
B. It applies the most recent stash but keeps it in the stack
C. It deletes the most recent stash without applying it
D. It lists all available stashes

10 Which Git command helps determine who modified a specific line in a file and in which commit?

A. git diff
B. git check-attr
C. git blame
D. git log

11 What is the purpose of an 'Annotated Tag' in Git?

A. It is stored as a full object in the database containing the tagger name, email, and date
B. It automatically updates when new commits are added
C. It is just a pointer to a specific commit
D. It allows you to tag a file instead of a commit

12 Which command is used to delete a local branch that has already been merged?

A. git branch -D <branch_name>
B. git checkout -d <branch_name>
C. git rm <branch_name>
D. git branch -d <branch_name>

13 When resolving a merge conflict, what must be done after editing the files to fix the conflict?

A. Run git push
B. Stage the files using git add
C. Run git commit immediately
D. Run git rebase --continue

14 What does the command git rebase -i HEAD~3 allow you to do?

A. Interactively modify, squash, or drop the last 3 commits
B. Merge the last 3 commits into a new branch
C. Stash the last 3 commits
D. Revert the last 3 commits

15 Which command creates a lightweight tag named 'v1.0'?

A. git tag --light v1.0
B. git tag v1.0
C. git tag -a v1.0 -m 'version 1.0'
D. git commit --tag v1.0

16 During a rebase, if you encounter conflicts, which command allows you to proceed after resolving them?

A. git rebase --continue
B. git rebase --abort
C. git rebase --skip
D. git commit

17 What does the command git diff branchA..branchB do?

A. Shows the common ancestor of both branches
B. Merges branchA into branchB
C. Shows the changes between the tips of branchA and branchB
D. Rebases branchB onto branchA

18 Why is it generally advised not to rebase public history?

A. It rewrites history, causing synchronization issues for other developers
B. It deletes the remote repository
C. It creates merge conflicts automatically
D. It consumes too much memory

19 Which option in git log draws a text-based graphical representation of the commit history?

A. git log --graph
B. git log --pretty
C. git log --chart
D. git log --draw

20 What is the command to list all current stashes?

A. git stash --verbose
B. git stash show
C. git stash list
D. git stash all

21 If you want to create a new branch from a specific stash, which command should you use?

A. git stash branch <branchname>
B. git checkout -b <branchname> stash
C. git stash pop <branchname>
D. git branch <branchname> --stash

22 What is the purpose of git merge --no-ff?

A. It prevents a merge commit from being created
B. It aborts the merge if conflicts are found
C. It performs a dry-run merge
D. It forces the creation of a merge commit even if a fast-forward is possible

23 How do you push a specific tag v1.0 to the remote repository?

A. git push origin --tags
B. git tag push v1.0
C. git commit --push v1.0
D. git push origin v1.0

24 Which command removes untracked files from the working tree?

A. git rm
B. git stash drop
C. git clean
D. git reset

25 In an interactive rebase, what does the squash command do?

A. Deletes the commit
B. Edits the commit message
C. Combines the commit with the previous one
D. Pauses the rebase

26 Which of the following describes a 'detached HEAD' state?

A. The repository has no commits
B. HEAD points directly to a commit instead of a branch reference
C. The remote repository is unreachable
D. There are uncommitted changes in the staging area

27 Which command would you use to view the commit history for a specific file?

A. git show <filename>
B. git diff <filename>
C. git status <filename>
D. git log <filename>

28 What happens when you run git stash apply?

A. The top stash is applied but remains in the stack
B. All stashes are applied
C. The stash is deleted
D. The top stash is applied and removed from the stack

29 How can you rename the current branch to 'main'?

A. git branch -m main
B. git checkout -b main
C. git branch --new main
D. git rename main

30 What is the purpose of git reflog?

A. To delete old logs
B. To view the history of branch updates and HEAD movements
C. To reference the logs of a specific tag
D. To view the commit logs of a remote repository

31 Which command deletes the most recent stash entry?

A. git stash drop
B. git stash delete
C. git stash remove
D. git stash pop --no-apply

32 You have unstaged changes in file.txt and want to discard them. Which command do you use?

A. git checkout -- file.txt
B. git rm file.txt
C. git reset file.txt
D. git stash pop

33 What does git tag -l 'v1.8*' do?

A. Deletes all tags starting with v1.8
B. Lists all tags matching the pattern v1.8*
C. Pushes tags starting with v1.8
D. Creates a tag named v1.8*

34 When performing a 3-way merge, which three commits are used?

A. The last three commits on the current branch
B. The two branch tips and their most recent common ancestor
C. The HEAD, the Staging Index, and the Working Directory
D. The local branch tip, the remote branch tip, and the stash

35 Which command allows you to stash untracked files as well?

A. git stash save
B. git stash -u
C. git stash --all
D. git stash --force

36 In an interactive rebase, what does drop do?

A. Removes the commit entirely from history
B. Stops the rebase process
C. Moves the commit to a new branch
D. Squashes the commit

37 To force a push after a rebase (since history changed), which command is used?

A. git push --hard
B. git push --overwrite
C. git push --force
D. git push --rebase

38 What command shows the difference between the staging area and the last commit?

A. git diff HEAD
B. All of the above
C. git status -v
D. git diff --staged

39 How do you apply a specific stash from the list, e.g., index 2?

A. git stash apply 2
B. git stash apply stash@{2}
C. git stash pop 2
D. git apply stash#2

40 What is the primary usage of git show?

A. To show the remote URL
B. To display metadata and content changes of a specific object (blob, tree, tag, or commit)
C. To show all branches
D. To show the current status of the repository

41 Which command would you use to verify if a tag is GPG signed?

A. git show --signature <tagname>
B. git verify <tagname>
C. git tag -v <tagname>
D. git tag --check <tagname>

42 If you want to modify the message of the most recent commit, which command is appropriate?

A. git commit --amend
B. git reset
C. git rebase
D. git config commit.message

43 What defines the structure of the Git history graph?

A. A Linked List
B. A Binary Search Tree
C. A Stack
D. A Directed Acyclic Graph (DAG)

44 Which command allows you to view the diff statistics (summary of insertions/deletions) rather than full code changes?

A. git diff --stat
B. git diff --summary
C. git diff --brief
D. git diff --count

45 How do you tag a past commit (not the current HEAD)?

A. You cannot tag past commits
B. git tag v1.0 HEAD~1
C. git tag v1.0 <commit_checksum>
D. git tag --past v1.0

46 Which command is used to discard all local changes in the working directory and staging area, resetting them to the last commit?

A. git reset --hard
B. git reset --mixed
C. git checkout .
D. git reset --soft

47 What is the equivalent of git merge that results in a cleaner history but modifies commit hashes?

A. git stash
B. git revert
C. git rebase
D. git cherry-pick

48 What happens if you delete a branch that has unmerged work using git branch -D?

A. The branch is moved to 'archive'
B. The commits are permanently lost immediately
C. The commits become dangling but can be recovered via reflog for a certain period
D. Git forbids the action

49 Which command shows the branches that have not yet been merged into the current branch?

A. git status
B. git branch --diff
C. git branch --no-merged
D. git branch --merged

50 In an interactive rebase, what does the reword instruction do?

A. Meld the commit into the previous one
B. Use the commit as is
C. Use the commit, but edit the commit message
D. Remove the commit