Unit 5: Version Control - Practice Quiz

CSE111 — Orientation To Computing 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What is Git mainly used for?

Overview of Git and GitHub Easy
A. Scanning files for viruses
B. Designing website layouts
C. Tracking changes in files
D. Creating database tables

2 What is GitHub?

Overview of Git and GitHub Easy
A. A platform for hosting Git repositories
B. A program for editing images
C. A language for creating websites
D. A tool for managing printers

3 Which statement correctly describes the relationship between Git and GitHub?

Overview of Git and GitHub Easy
A. Git creates accounts, while GitHub installs software
B. Git hosts websites, while GitHub edits files
C. Git stores passwords, while GitHub scans files
D. Git tracks versions, while GitHub hosts repositories

4 Which command checks whether Git is installed and displays its version?

install git and create a GitHub account Easy
A. git --check
B. git --install
C. git --account
D. git --version

5 What information is commonly required when creating a GitHub account?

install git and create a GitHub account Easy
A. Email address and username
B. Repository name and branch
C. Commit message and filename
D. Folder path and file type

6 Which command sets the global Git username?

install git and create a GitHub account Easy
A. git profile --create name "Alex"
B. git user --install name "Alex"
C. git account --global name "Alex"
D. git config --global user.name "Alex"

7 Which command creates a new Git repository in the current folder?

create a local git repository Easy
A. git init
B. git open
C. git start
D. git create

8 What hidden directory is created when git init is run successfully?

create a local git repository Easy
A. .branch
B. .git
C. .commit
D. .github

9 Which command shows the current state of files in a local repository?

create a local git repository Easy
A. git state
B. git inspect
C. git display
D. git status

10 After creating a new file, how does Git usually describe it before it is added?

add a new file to the repository Easy
A. Merged
B. Deleted
C. Committed
D. Untracked

11 Which command adds notes.txt to the staging area?

add a new file to the repository Easy
A. git commit notes.txt
B. git stage --new notes.txt
C. git add notes.txt
D. git track --save notes.txt

12 Which command stages all current changes in the working directory?

add a new file to the repository Easy
A. git add .
B. git branch .
C. git commit .
D. git init .

13 What is the purpose of Git's staging area?

add a new file to the repository Easy
A. To prepare changes for a commit
B. To install Git on a computer
C. To publish files on a website
D. To remove the repository history

14 What is a commit in Git?

Creating a commit Easy
A. A registered GitHub account
B. A newly installed Git program
C. A saved snapshot of changes
D. A deleted repository folder

15 Which command creates a commit with the message Add notes?

Creating a commit Easy
A. git add -m "Add notes"
B. git commit -m "Add notes"
C. git init -m "Add notes"
D. git save -m "Add notes"

16 What does the -m option represent in git commit -m "Update file"?

Creating a commit Easy
A. Modified file
B. Merge request
C. Main branch
D. Commit message

17 Which command displays the repository's commit history?

Creating a commit Easy
A. git history
B. git log
C. git list
D. git record

18 What is the main purpose of a Git branch?

Creation of a new Branch Profile. Easy
A. To create a GitHub password
B. To develop changes separately
C. To install another Git version
D. To delete all previous commits

19 Which command creates a new branch named feature?

Creation of a new Branch Profile. Easy
A. git commit feature
B. git add feature
C. git init feature
D. git branch feature

20 Which command switches to an existing branch named feature?

Creation of a new Branch Profile. Easy
A. git commit feature
B. git branch feature
C. git status feature
D. git switch feature

21 A developer needs to record project versions while working offline and later share them with a team. Which approach best meets both requirements?

Overview of Git and GitHub Medium
A. Use Git locally and push the repository to GitHub later
B. Use Git only because it automatically shares every commit
C. Use GitHub locally and install Git only when sharing
D. Use GitHub only because it records offline file changes

22 A project repository was pushed to GitHub before its local folder was accidentally deleted. Which action can restore a local working copy?

Overview of Git and GitHub Medium
A. Run git clone with the GitHub repository URL
B. Run git commit with the GitHub repository URL
C. Run git init with the GitHub repository URL
D. Run git status with the GitHub repository URL

23 Two developers commit different changes to the same project. Which Git feature makes it possible to identify and combine their recorded work?

Overview of Git and GitHub Medium
A. Commit history and merging
B. Account passwords and themes
C. Browser bookmarks and downloads
D. Folder compression and extraction

24 After installing Git, which command should a student run to confirm that the command-line installation is available?

install git and create a GitHub account Medium
A. git --confirm
B. git --install
C. git --account
D. git --version

25 A student has created a GitHub account but new commits show an incorrect author name and email. Which commands should be used to set the global commit identity?

install git and create a GitHub account Medium
A. git config --global account.name and git config --global account.email
B. git account --global profile.name and git account --global profile.email
C. git profile --global user.name and git profile --global user.email
D. git config --global user.name and git config --global user.email

26 A student can sign in to GitHub in a browser, but an HTTPS push requests authentication and rejects the account password. What should the student generally use instead?

install git and create a GitHub account Medium
A. A local Git commit message
B. A repository branch name
C. A Git configuration email
D. A GitHub personal access token

27 A folder named portfolio already contains project files. Which command sequence turns that folder into a local Git repository without creating another project folder?

create a local git repository Medium
A. cd portfolio followed by git init
B. git add portfolio followed by git create
C. cd portfolio followed by git clone
D. git clone portfolio followed by git init

28 A student accidentally runs git init inside a subfolder named website, although website should be tracked as an ordinary part of the parent repository. What is the most appropriate correction before staging it?

create a local git repository Medium
A. Rename website/.git and push it directly to GitHub
B. Keep both .git directories and commit from either location
C. Remove website/.git and stage website from the parent repository
D. Remove the parent's .git and commit only from website

29 After running git init, a student wants to verify that the current folder is recognized as a repository and inspect its file state. Which command is most suitable?

create a local git repository Medium
A. git install
B. git status
C. git publish
D. git account

30 A newly created file named notes.txt appears under untracked files in git status. Which command moves it into the staging area?

add a new file to the repository Medium
A. git track notes.txt
B. git add notes.txt
C. git commit notes.txt
D. git push notes.txt

31 Three files have been modified, but no files are currently staged. A student wants the next commit to include only report.md. Which command should be run?

add a new file to the repository Medium
A. git add --all
B. git commit -a
C. git add .
D. git add report.md

32 A tracked file named config.env is added to .gitignore, but Git continues to report modifications to it. Which action is needed to stop tracking the file while keeping the local copy?

add a new file to the repository Medium
A. Run git rm config.env and recreate the repository
B. Run git reset config.env and delete .gitignore
C. Run git rm --cached config.env and commit the change
D. Run git clean config.env and amend every commit

33 A repository contains one staged file and two modified but unstaged files. What will a normal git commit record?

Creating a commit Medium
A. Only the staged file content
B. Only the unstaged file content
C. No file content at all
D. All modified file content

34 A student stages draft.md, edits it again, and then commits without running git add a second time. Which version is included in the commit?

Creating a commit Medium
A. The version present when git add was last run
B. A merged version containing both file snapshots
C. The version present after the final unstaged edit
D. No version because Git cancels the commit

35 A developer intentionally needs a milestone commit even though no files have changed. Which command can create it?

Creating a commit Medium
A. git commit --force-empty -m Milestone
B. git add --empty -m Milestone
C. git commit --allow-empty -m Milestone
D. git init --allow-empty -m Milestone

36 A student wants to inspect the latest commit's message, author, date, and file changes. Which command is most appropriate?

Creating a commit Medium
A. git init HEAD
B. git push HEAD
C. git show HEAD
D. git add HEAD

37 While on main, a student wants to create a branch named profile and immediately begin working on it. Which command is suitable?

Creation of a new Branch Profile. Medium
A. git switch -d profile
B. git branch -d profile
C. git switch -c profile
D. git merge -c profile

38 A student creates profile from main and makes a new commit on profile. Before any merge occurs, what is true about main?

Creation of a new Branch Profile. Medium
A. main becomes a copy of the staging area
B. main is automatically deleted by Git
C. main automatically points to the profile commit
D. main still points to its earlier commit

39 The work on branch profile is complete and should be integrated into main. Which command sequence performs the merge into the correct branch?

Creation of a new Branch Profile. Medium
A. git switch profile followed by git merge main
B. git merge main followed by git switch profile
C. git branch main followed by git add profile
D. git switch main followed by git merge profile

40 A local branch named profile has no corresponding branch on GitHub. Which command both pushes it to origin and establishes its upstream relationship?

Creation of a new Branch Profile. Medium
A. git branch -u origin profile
B. git pull -u origin profile
C. git push -u origin profile
D. git clone -u origin profile

41 A developer creates three commits while disconnected from the internet. Which fact best explains why this is possible?

Overview of Git and GitHub Hard
A. Git creates commits locally only when the remote-tracking branch is current.
B. Git stores repository history locally, so commits do not require GitHub access.
C. Git temporarily stores commits outside the repository until a remote responds.
D. GitHub queues offline commits and uploads them when connectivity returns.

42 A local branch and its GitHub counterpart each contain a new commit that the other does not have. Which description is accurate?

Overview of Git and GitHub Hard
A. The branches are synchronized because each contains exactly one new commit.
B. The branches have diverged and must be integrated before a normal push succeeds.
C. The local commit automatically replaces the GitHub commit during the next fetch.
D. The GitHub commit automatically replaces the local commit during the next push.

43 Which statement correctly distinguishes a GitHub fork from a Git branch?

Overview of Git and GitHub Hard
A. A fork records uncommitted changes, while a branch records only committed changes.
B. A fork is a copied repository under another account, while a branch is a reference within a repository.
C. A fork and a branch are equivalent references but use different Git commands.
D. A fork is a local commit reference, while a branch is always stored only on GitHub.

44 Git is installed successfully, but the first commit fails with Author identity unknown. Which action directly resolves the problem for all repositories owned by the current operating-system user?

install git and create a GitHub account Hard
A. Add the GitHub username and password with git remote add origin.
B. Reinstall Git while using the GitHub email as the installation path.
C. Run git config --global user.name "Name" and git config --global user.email "email".
D. Sign in to GitHub in a browser before repeating git commit.

45 A user can open a public GitHub repository in a browser but receives an authentication error when pushing over HTTPS. Git itself is installed correctly. What is the most likely missing requirement?

install git and create a GitHub account Hard
A. A valid GitHub authentication method, such as a personal access token or credential helper.
B. A global Git alias that translates push into an authenticated command.
C. A public GitHub profile containing the same display name as the commit author.
D. A second local repository initialized inside the first repository's working tree.

46 A student configures Git with a GitHub-provided private no-reply email address. What is the most accurate consequence?

install git and create a GitHub account Hard
A. The address authenticates command-line pushes without a token or an SSH key.
B. Commits can still be attributed to the account if that exact address belongs to the account.
C. Git refuses to create commits because no-reply addresses are invalid author identities.
D. GitHub accepts the commits but permanently prevents them from appearing in history.

47 A directory already contains source files but has never used Git. After running git init, which statement is correct?

create a local git repository Hard
A. Git immediately creates a commit containing every existing source file.
B. Git creates repository metadata, but the existing source files remain untracked.
C. Git uploads the existing source files to a new private GitHub repository.
D. Git deletes files that are not listed in a generated .gitignore file.

48 Immediately after git init in an empty directory, a student runs git log and receives a message indicating that the current branch has no commits. Which interpretation is correct?

create a local git repository Hard
A. The repository is corrupted because every initialized branch must contain one commit.
B. The repository exists, but its initial branch is unborn until the first commit.
C. The repository is detached because HEAD cannot refer to a branch before cloning.
D. The repository exists only in memory until a remote repository is configured.

49 A student wants a local copy of an existing GitHub repository, including its commit history and configured source remote. Which command is most appropriate?

create a local git repository Hard
A. git init <repository-url>
B. git add <repository-url>
C. git clone <repository-url>
D. git commit <repository-url>

50 A project has been initialized locally and committed, but git push -u origin main reports that origin is not a repository. What should be checked first?

create a local git repository Hard
A. Whether every project file has been modified since the most recent local commit.
B. Whether the local repository contains more than one independently created branch.
C. Whether origin exists and points to the correct accessible GitHub repository URL.
D. Whether the GitHub repository has a .git directory visible in its web interface.

51 A student creates report.md, runs git add report.md, and then edits the file again before committing. What does Git now contain?

add a new file to the repository Hard
A. The file becomes untracked because it changed after being added to the index.
B. The index has the later version, while the working tree restores the earlier version.
C. The index has the earlier version, while the working tree has the later version.
D. The index and working tree both automatically contain the later version.

52 A tracked file named secrets.txt is later added to .gitignore, but Git continues to report modifications to it. Why?

add a new file to the repository Hard
A. The .gitignore file takes effect only after the repository is cloned again.
B. Ignore rules normally affect untracked files and do not automatically untrack existing files.
C. Tracked files bypass .gitignore only when they are stored on the initial branch.
D. Ignore rules apply only to directories and cannot match individual tracked files.

53 A file contains two unrelated changes, but only one should be included in the next commit. Which command is designed to interactively stage selected change hunks?

add a new file to the repository Hard
A. git commit -a <file>
B. git add -f <file>
C. git add -p <file>
D. git checkout -b <file>

54 A new file matches an ignore rule, but the student intentionally wants to stage it once without changing .gitignore. Which command addresses this case?

add a new file to the repository Hard
A. git add --amend <file>
B. git add -p <file>
C. git add -u <file>
D. git add -f <file>

55 A repository has one staged change and one different unstaged change. The student runs git commit -m "Update". What is included in the new commit?

Creating a commit Hard
A. Only the unstaged change is included in the new commit.
B. Both staged and unstaged changes are included in the new commit.
C. Only the staged change is included in the new commit.
D. Neither change is included because the working tree is not clean.

56 A student commits a file, changes only the commit message with git commit --amend, and notices that the commit hash changes. What best explains this?

Creating a commit Hard
A. The commit message is part of the commit data used to calculate its identifier.
B. Git assigns random identifiers whenever an existing branch receives any command.
C. Amending converts the commit into a merge commit with a second hidden parent.
D. The hash changes only because the working-tree file was automatically modified.

57 A developer accidentally stages debug.log with valid source changes. The file has not yet been committed, and its working copy must be preserved. Which command removes it from the staging area in modern Git?

Creating a commit Hard
A. git restore debug.log
B. git branch -d debug.log
C. git restore --staged debug.log
D. git clean -f debug.log

58 While on main, a student runs git switch -c profile. What is the immediate result?

Creation of a new Branch Profile. Hard
A. A GitHub profile is created and connected to the current local repository.
B. A profile commit is created without changing the currently active branch.
C. A profile branch is created from the remote branch but remains inactive.
D. A profile branch is created at the current commit and becomes the active branch.

59 A student creates and switches to profile while main has uncommitted modifications. No checkout conflict occurs. What happens to those modifications?

Creation of a new Branch Profile. Hard
A. They are permanently discarded when profile becomes the active branch.
B. They normally remain in the working tree after switching to profile.
C. They are automatically committed as the first change on profile.
D. They are automatically committed to main before the branch is created.

60 The local profile branch has one commit and no remote-tracking configuration. Which command both publishes it to origin and establishes the usual upstream relationship?

Creation of a new Branch Profile. Hard
A. git fetch -u origin profile
B. git push -u origin profile
C. git remote add origin profile
D. git branch -u origin profile