Unit 5: Version Control - Practice Quiz
1 What is Git mainly used for?
2 What is GitHub?
3 Which statement correctly describes the relationship between Git and GitHub?
4 Which command checks whether Git is installed and displays its version?
git --check
git --install
git --account
git --version
5 What information is commonly required when creating a GitHub account?
6 Which command sets the global Git username?
git profile --create name "Alex"
git user --install name "Alex"
git account --global name "Alex"
git config --global user.name "Alex"
7 Which command creates a new Git repository in the current folder?
git init
git open
git start
git create
8
What hidden directory is created when git init is run successfully?
.branch
.git
.commit
.github
9 Which command shows the current state of files in a local repository?
git state
git inspect
git display
git status
10 After creating a new file, how does Git usually describe it before it is added?
11
Which command adds notes.txt to the staging area?
git commit notes.txt
git stage --new notes.txt
git add notes.txt
git track --save notes.txt
12 Which command stages all current changes in the working directory?
git add .
git branch .
git commit .
git init .
13 What is the purpose of Git's staging area?
14 What is a commit in Git?
15
Which command creates a commit with the message Add notes?
git add -m "Add notes"
git commit -m "Add notes"
git init -m "Add notes"
git save -m "Add notes"
16
What does the -m option represent in git commit -m "Update file"?
17 Which command displays the repository's commit history?
git history
git log
git list
git record
18 What is the main purpose of a Git branch?
19
Which command creates a new branch named feature?
git commit feature
git add feature
git init feature
git branch feature
20
Which command switches to an existing branch named feature?
git commit feature
git branch feature
git status feature
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?
22 A project repository was pushed to GitHub before its local folder was accidentally deleted. Which action can restore a local working copy?
git clone with the GitHub repository URL
git commit with the GitHub repository URL
git init with the GitHub repository URL
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?
24 After installing Git, which command should a student run to confirm that the command-line installation is available?
git --confirm
git --install
git --account
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?
git config --global account.name and git config --global account.email
git account --global profile.name and git account --global profile.email
git profile --global user.name and git profile --global user.email
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?
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?
cd portfolio followed by git init
git add portfolio followed by git create
cd portfolio followed by git clone
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?
website/.git and push it directly to GitHub
.git directories and commit from either location
website/.git and stage website from the parent repository
.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?
git install
git status
git publish
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?
git track notes.txt
git add notes.txt
git commit notes.txt
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?
git add --all
git commit -a
git add .
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?
git rm config.env and recreate the repository
git reset config.env and delete .gitignore
git rm --cached config.env and commit the change
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?
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?
git add was last run
35 A developer intentionally needs a milestone commit even though no files have changed. Which command can create it?
git commit --force-empty -m Milestone
git add --empty -m Milestone
git commit --allow-empty -m Milestone
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?
git init HEAD
git push HEAD
git show HEAD
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?
git switch -d profile
git branch -d profile
git switch -c profile
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?
main becomes a copy of the staging area
main is automatically deleted by Git
main automatically points to the profile commit
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?
git switch profile followed by git merge main
git merge main followed by git switch profile
git branch main followed by git add profile
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?
git branch -u origin profile
git pull -u origin profile
git push -u origin profile
git clone -u origin profile
41 A developer creates three commits while disconnected from the internet. Which fact best explains why this is possible?
42 A local branch and its GitHub counterpart each contain a new commit that the other does not have. Which description is accurate?
43 Which statement correctly distinguishes a GitHub fork from a Git branch?
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?
git remote add origin.
git config --global user.name "Name" and git config --global user.email "email".
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?
push into an authenticated command.
46 A student configures Git with a GitHub-provided private no-reply email address. What is the most accurate consequence?
47
A directory already contains source files but has never used Git. After running git init, which statement is correct?
.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?
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?
git init <repository-url>
git add <repository-url>
git clone <repository-url>
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?
origin exists and points to the correct accessible GitHub repository URL.
.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?
52
A tracked file named secrets.txt is later added to .gitignore, but Git continues to report modifications to it. Why?
.gitignore file takes effect only after the repository is cloned again.
.gitignore only when they are stored on the initial branch.
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?
git commit -a <file>
git add -f <file>
git add -p <file>
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?
git add --amend <file>
git add -p <file>
git add -u <file>
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?
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?
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?
git restore debug.log
git branch -d debug.log
git restore --staged debug.log
git clean -f debug.log
58
While on main, a student runs git switch -c profile. What is the immediate result?
profile commit is created without changing the currently active branch.
profile branch is created from the remote branch but remains inactive.
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?
profile becomes the active branch.
profile.
profile.
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?
git fetch -u origin profile
git push -u origin profile
git remote add origin profile
git branch -u origin profile
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 →