Git MCQs

Git MCQs

The following Git MCQs have been compiled by our experts through research, in order to test your knowledge of the subject of Git. We encourage you to answer these multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: What command creates a git repository in your current directory?

A.   git begin

B.   git init

C.   git prepare

D.   git start

2: How do you add all the files in a subdirectory called ../project/experiment?

A.   git add ../project/experiment/

B.   git add ../project/experiment

C.   git add ../project/experiment/*

D.   git add ../

E.   git add project/

3: What shortcut creates and checks out a branch simultaneously?

A.   there is no shortcut: git branch <branchname>; git checkout <branchname> is the fastet way

B.   git branch --checkout <branchname>

C.   git-branch-and-checkout <branchname>

D.   git checkout -b <branchname>

4: Which file in a git repository specifies intentionally untracked files that git should ignore?

A.   .gitignore

B.   .git-exclude

C.   .git-ignore

D.   .gitexclude

5: What file is used inside of a repository, to list files that should be ignored by git?

A.   .git

B.   .noadd

C.   .ignore

D.   .gitignore

6: Which of the following is to copy a remote repository.

A.   git clone

B.   git add

C.   git init

D.   git copy

E.   git start

7: Which of the following is not a git command

A.   git push

B.   git add

C.   git moment

D.   git pull

E.   git stash

8: What is the main branch of a git repo commonly called?

A.   current

B.   main


D.   master

9: How would one add Remote Repositories?

A.   git remote add [shortname] [url]

B.   git remote [shortname] [url]

10: What is the command for displaying the version of git being used?

A.   git --help

B.   git --v

C.   git --bare

D.   git --version

11: How many remote servers can 1 Git repo pull changes from?

A.   128

B.   64

C.   32

D.   No Limit

E.   16

12: What does adding the -m option to git commit do?

A.   Uses the given message as the commit message

B.   Commits to master regardless of the current branch

C.   Halts the commit if the current branch is the master branch

D.   Commits without message

13: CSS is also created and maintained by group of people within

A.   W3D

B.   W3S

C.   W3C

D.   W3F

14: Is possible to have a global .gitignore file?

A.   Yes

B.   No

15: How do you determine the current state of the project?

A.   $ git stat

B.   $ git status

C.   git stat

D.   (all of these options)

16: Who invented Git?

A.   Steve Jobs

B.   Linus Torvalds

C.   Mark Zuckerberg

D.   Bill Gates

E.   Steve Wozniak

17: What is the command for viewing a list of recent commits?

A.   git bisect

B.   git list

C.   git merge

D.   git log

E.   git show

18: What is the command for switching branches?

A.   git switch <branch name>

B.   git pull <branch name>

C.   git checkout <branch name>

D.   git fetch <branch name>

E.   git clone <branch name>

19: How do you add all files in current directory to git repository?

A.   git add all

B.   git add ./

C.   git add

D.   git add .

20: To update your local repo, which command will you use?

A.   git push

B.   git pull

C.   git status

D.   git merge

E.   git rebase

21: Which command shows you the version of your git installation.

A.   git --info

B.   git -v

C.   (none of these)

D.   which git

E.   git --version

22: What is the correct way to add multiple files to the staging area?

A.   git add file1.txt, file2.txt, file3.txt

B.   git include file1.txt file2.txt file3.txt

C.   git add file1.txt fil2.txt file3.txt

D.   git include file1.txt, file2.txt, file3.txt

23: How do you retrieve changes from a remote repo?

A.   git pull origin master

B.   git pull master

C.   git pull master origin

D.   git remote master

E.   git get origin master

24: To limit the "git diff" comparison to the file foo.txt, use:

A.   git diff foo.txt

B.   git diff

C.   all are correct

D.   git diff foo

25: You want to revert 'notes.txt' to the version in the most recent commit.

A.   git drop HEAD /path/to/notes.txt

B.   git dropback -- /path/to/notes.txt

C.   git checkout -- /path/to/notes.txt

26: What feature really makes GIT stand apart from nearly every other SCM

A.   Commit Mesage

B.   Branching Model

C.   Command

D.   Staging Area

27: Which command will restore the current branch and working copy to the exact state it was at before the most recent commit?

A.   git revert --no-edit HEAD

B.   git reset --hard HEAD^

C.   git commit --revert

D.   git checkout HEAD@{1}

28: How do you undo all changes since your last commit?

A.   git reset --hard

B.   git undo <branch>

C.   git reset <branch>

D.   git reset

E.   git undo --hard

29: How can I get the commit ID?

A.   git --version

B.   git log

C.   git id

D.   git ID

E.   git info

30: How do you stage all changes?

A.   git add all

B.   git stage all

C.   git stage .

D.   git add .

31: Which one of the following commands lists REMOTE branches only?

A.   git branch --remote r

B.   git branch -a

C.   git branch -r

D.   git branch --all

32: Which command deletes the branch named "stinky" regardless of merge status ?

A.   git delete stinky

B.   git branch --remove stinky

C.   git branch -D stinky

D.   git rm stinky

33: What command undoes all changes since the last commit?

A.   git undo

B.   git reset

C.   git revert

D.   git rm

34: How to display a list of configuration parameters?

A.   git configuration

B.   git config -l

C.   git config

D.   git configuration -l

E.   No way of doing that, except by editing the config file.

35: The command "git stash list" should print the following:

A.   All stashes currently on the stack

B.   "Successfully stashed 'list'"

C.   None. This is an invalid command.

D.   Information for stash called "list"

36: A staged file is

A.   An ignored file

B.   A file added to the index

C.   A committed file

D.   It does not exist

E.   A file that has been modified

37: What language is used in Git

A.   C++



D.   C

E.   C#

38: True or False? Is Git a centralized version control system.

A.   True

B.   False

39: Which of the following options enables helpful colorization of command line output?

A.   git config --color

B.   git change --color auto

C.   git config --global color.ui auto

40: What option suppresses output for git rm?

A.   --verbose=false

B.   --short

C.   --summary

D.   --quiet

41: How do you add only certain parts of a file to the index?

A.   git add -p

B.   git add partial

C.   git add patch

D.   git add -s

42: What's the purpose of 'git bisect' ?

A.   Cancel the previous commit (if not pushed)

B.   Find your last commit

C.   Find the commit which introduced a bug

D.   Sign the last commit (with a gpg key)

E.   Reset a file to the last commit

43: What git feature allows you to embed separate repos?

A.   submodules

B.   subrepos

C.   remotes

44: How do you add another git repository as a directory of your repository

A.   git module <repository> <local directory>

B.   git remote add <repository> <local directory>

C.   git add <local directory> <repository>

D.   git submodule add <repository> <local directory>

45: When pushing to a remote server, what is the only type of merge that is accepted by default?

A.   All are accepted

B.   Round-Robin

C.   Recursive

D.   Fast-Forward

46: Which command will show what revision and author last modified each line of a file?

A.   git bisect

B.   git blame

C.   git examine

D.   git review

E.   git revision

47: Using which command you can apply a certain commit to the current branch, using the commit's SHA1?

A.   commit

B.   patch

C.   rebase

D.   cherry-pick

E.   pull

48: What is the default text editor used by git?

A.   notepad

B.   vim

C.   emacs

D.   system default

E.   a browser

49: What is the "git status" option used to output the shortened project status?

A.   -s

B.   --brief

C.   --verbose=false

D.   -b

50: `git rebase <upstream>` will:

A.   Re-pack GITs object store for <upstream>

B.   Replay the changes made in <upstream> on top of the changes made in the current branch (as if the changes in <upstream> had been done after the changes in the current branch)

C.   Replay the changes made in the current branch on top of the changes made in <upstream> (as if the changes in the current branch had been done after the changes in <upstream>)

D.   Push the changes in the current repository into a named branch in <upstream>