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. Tracking changes in files
B. Designing website layouts
C. Scanning files for viruses
D. Creating database tables

2 What is GitHub?

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

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 stores passwords, while GitHub scans files
C. Git tracks versions, while GitHub hosts repositories
D. Git hosts websites, while GitHub edits files

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 --version
C. git --account
D. git --install

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

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

6 Which command sets the global Git username?

install git and create a GitHub account Easy
A. git account --global name "Alex"
B. git profile --create name "Alex"
C. git config --global user.name "Alex"
D. git user --install 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 create
C. git open
D. git start

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

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

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

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

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. Deleted
B. Untracked
C. Merged
D. Committed

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

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

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

add a new file to the repository Easy
A. git commit .
B. git branch .
C. git add .
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 publish files on a website
C. To install Git on a computer
D. To remove the repository history

14 What is a commit in Git?

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

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

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

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

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

17 Which command displays the repository's commit history?

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

18 What is the main purpose of a Git branch?

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

19 Which command creates a new branch named feature?

Creation of a new Branch Profile. Easy
A. git init feature
B. git commit feature
C. git add 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 status feature
C. git branch 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 GitHub locally and install Git only when sharing
B. Use GitHub only because it records offline file changes
C. Use Git only because it automatically shares every commit
D. Use Git locally and push the repository to GitHub later

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 status with the GitHub repository URL
C. Run git init with the GitHub repository URL
D. Run git commit 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. Browser bookmarks and downloads
B. Commit history and merging
C. Folder compression and extraction
D. Account passwords and themes

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 --version
D. git --account

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 profile --global user.name and git profile --global user.email
C. git account --global profile.name and git account --global profile.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 GitHub personal access token
B. A local Git commit message
C. A repository branch name
D. A Git configuration email

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. git add portfolio followed by git create
B. cd portfolio followed by git init
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. Remove website/.git and stage website from the parent repository
B. Rename website/.git and push it directly to GitHub
C. Remove the parent's .git and commit only from website
D. Keep both .git directories and commit from either location

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 status
B. git account
C. git publish
D. git install

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 push notes.txt
B. git commit notes.txt
C. git add notes.txt
D. git track 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 .
B. git add --all
C. git commit -a
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 rm --cached config.env and commit the change
C. Run git reset config.env and delete .gitignore
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 unstaged file content
B. No file content at all
C. Only the staged file content
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. A merged version containing both file snapshots
B. No version because Git cancels the commit
C. The version present when git add was last run
D. The version present after the final unstaged edit

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 init --allow-empty -m Milestone
B. git commit --force-empty -m Milestone
C. git add --empty -m Milestone
D. git commit --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 add HEAD
C. git push HEAD
D. git show 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 switch -c profile
C. git branch -d 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 automatically points to the profile commit
B. main is automatically deleted by Git
C. main still points to its earlier commit
D. main becomes a copy of the staging area

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 branch main followed by git add profile
B. git switch main followed by git merge profile
C. git switch profile followed by git merge main
D. git merge main followed by git switch 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 pull -u origin profile
B. git branch -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 temporarily stores commits outside the repository until a remote responds.
B. GitHub queues offline commits and uploads them when connectivity returns.
C. Git stores repository history locally, so commits do not require GitHub access.
D. Git creates commits locally only when the remote-tracking branch is current.

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 local commit automatically replaces the GitHub commit during the next fetch.
B. The GitHub commit automatically replaces the local commit during the next push.
C. The branches are synchronized because each contains exactly one new commit.
D. The branches have diverged and must be integrated before a normal push succeeds.

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 local commit reference, while a branch is always stored only on GitHub.
C. A fork and a branch are equivalent references but use different Git commands.
D. A fork is a copied repository under another account, while a branch is a reference within a repository.

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. Sign in to GitHub in a browser before repeating git commit.
B. Add the GitHub username and password with git remote add origin.
C. Run git config --global user.name "Name" and git config --global user.email "email".
D. Reinstall Git while using the GitHub email as the installation path.

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 public GitHub profile containing the same display name as the commit author.
B. A global Git alias that translates push into an authenticated command.
C. A valid GitHub authentication method, such as a personal access token or credential helper.
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 deletes files that are not listed in a generated .gitignore 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 immediately creates a commit containing every existing source 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 exists only in memory until a remote repository is configured.
B. The repository is corrupted because every initialized branch must contain one commit.
C. The repository exists, but its initial branch is unborn until the first commit.
D. The repository is detached because HEAD cannot refer to a branch before cloning.

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 add <repository-url>
B. git commit <repository-url>
C. git clone <repository-url>
D. git init <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 origin exists and points to the correct accessible GitHub repository URL.
B. Whether the GitHub repository has a .git directory visible in its web interface.
C. Whether every project file has been modified since the most recent local commit.
D. Whether the local repository contains more than one independently created branch.

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 index has the earlier version, while the working tree has the later version.
B. The index has the later version, while the working tree restores the earlier version.
C. The file becomes untracked because it changed after being added to the index.
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. Ignore rules apply only to directories and cannot match individual tracked files.
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. The .gitignore file takes effect only after the repository is cloned again.

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 checkout -b <file>
B. git add -p <file>
C. git add -f <file>
D. git commit -a <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 -u <file>
B. git add --amend <file>
C. git add -p <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 staged change is included in the new commit.
B. Only the unstaged change is included in the new commit.
C. Both staged and unstaged changes are 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. Amending converts the commit into a merge commit with a second hidden parent.
B. Git assigns random identifiers whenever an existing branch receives any command.
C. The hash changes only because the working-tree file was automatically modified.
D. The commit message is part of the commit data used to calculate its identifier.

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 clean -f debug.log
B. git restore --staged debug.log
C. git restore debug.log
D. git branch -d 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 profile branch is created at the current commit and becomes the active branch.
B. A GitHub profile is created and connected to the current local repository.
C. A profile commit is created without changing the currently active branch.
D. A profile branch is created from the remote branch but remains inactive.

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 are automatically committed to main before the branch is created.
C. They are automatically committed as the first change on profile.
D. They normally remain in the working tree after switching to profile.

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