Please answer the quiz and click the "Test" button at the bottom right.This quiz is part of the DevOpsTheHardWay course.
Git - Basics - multichoice questions
Question 1
Given:
$ git init testrepo
$ cd testrepo
$ git commit -m "my first commit"
What is wrong?
- You forgot to add files to the staging area before committing.
- The git commit command is missing the
-a
flag to include all changes. - The repository isn't initialized.
- The initial commit requires the
--allow-empty
flag because there are no changes.
Question 2
When you clone a repository, which of the following statements is true?
- Some files are not tracked.
- None of the files are tracked.
- All files are tracked.
- Only new files added after the clone are tracked.
Question 3
After running git add .
(staging all files), what would be the output of git diff
?
- The differences between the working directory and the staging area.
- The differences between the working directory and the latest commit.
- The differences between the staging area and the latest commit.
- No output, because there are no differences to show.
Question 4
What does the HEAD
in Git represent?
- The most recent commit in the repository.
- The current branch name.
- The commit where your working directory is currently pointing.
- The first commit in the repository.
Question 5
Given:
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test_it
Untracked files:
(use "git add <file>..." to include in what will be committed)
DATA
Running git commit -a -m 'Add new benchmarks'
will:
- Commit the changes to both
test_it
andDATA
. - Commit the changes to
test_it
only, and leaveDATA
untracked. - Commit the changes to
DATA
only, and ignoretest_it
. - Fail to commit because
DATA
is untracked.
Question 6
Adding the -a
option to the git commit
command makes Git:
- Automatically stage all changes to tracked files and include them in the commit.
- Automatically add all new, untracked files to the commit.
- Automatically discard all changes in the working directory before committing.
- Automatically merge changes from the remote repository before committing.
Question 7
Given:
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: README
What is the status of the README
?
- The
README
file is untracked and has not been added to the staging area. - The
README
file is modified and needs to be committed. - The
README
file is new, has been added to the staging area, and is ready to be committed. - The
README
file has been deleted and is staged for removal.
Question 8
After modifying the config.json
files in a repository, you decide to discard the changes. What command can you use?
-
git reset --hard config.json
-
git revert config.json
-
git checkout -- config.json
-
git stash