MCQ Git
MCQ Git
A
$ git message "Fix error in xxxx"
B
$ git add "Fix error in xxxx"
C
$ git commit "Fix error in xxxx"
D
$ git commit -m "Fix error in xxxx"
Answer
D
2. What is the correct syntax for committing all changes with a message?
A
$ git message -am "Fix error in xxxx"
B
$ git add -a "Fix error in xxxx"
C
$ git commit -a "Fix error in xxxx"
D
$ git commit -am "Fix error in xxxx"
Answer
D
3. Which comes first _____?
A
$ git add
B
$ git commit
Answer
A
4. You can type “git status” at any time in a directory controlled by git to check
the status of your files.
A True
B False
Answer
A
5. We have just created a new file called “home.html”. Which of the following
will add this file so that we can commit it in git?
A
$ git add home.html
B
$ git add new
C
$ git add -a home.html
D
$ git git commit home.html
Answer
A
6. Which of the following commands used to show all parameters in git?
A
$ git config --list
B
$ git config -a
C
$ git config --all
D
$ git config --parameters --list
Answer
A
7. Which of the following commands used to return to the master branch?
A
$ git checkout origin
B
$ git checkout -b master
C
$ git checkout master
D
$ git checkout branche
Answer
C
8. Which of the following commands used to undo a commit?
A
$ git reset <commit>
B
$ git revert <commit>
C
$ git reset --hard origin/master
D
$ git init
Answer
B
9. Which of the following commands used to permanently cancel a commit?
A
$ git reset <commit>
B
$ git revert <commit>
C
$ git reset --hard origin/master
D
$ git init
Answer
A
10. How to create a new branch and switch to it directly?
A
$ git checkout <branch-name>
B
$ git branch <branch-name>
C
$ git checkout -b <branch-name>
D
$ git branch -new <branch-name>
Answer
C
MCQ Practice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to
prepare for tests and interviews.READ MORE
Git MCQ Set 1
1. What is full form of VCS?
Explanation
Correct Option :D.
2. Git is a __________
Explanation
Correct Option :A.
D. Both B & C
Explanation
Correct Option :D.
A. Only 1 & 2
B. Only 1 & 3
C. Only 2 & 3
Explanation
Correct Option :D.
o R
5. The files that can be committed are always present in git
A. working directory
B. staging area
C. unstaged area
Explanation
Correct Option :B.
B. .Net project
Explanation
Correct Option :D.
A. staging area
B. fork
C. branch
D. stem
Explanation
Correct Option :D.
C. Pull operation copies the changes from a local repository to remote repository
Explanation
Correct Option :C.
Git MCQ Set 2
1. Which of the following is example of distributed version control?
A. Git
B. Mercurial
C. SVN
D. Both A & B
Explanation
Correct Option :D.
A. Dennis Ritchie
B. Linus Torvalds
C. Linus Babbage
D. James Gosling
Explanation
Correct Option :B.
3. Which of the following are the stages in which your git file can reside?
A. modified
B. staged
C. committed
Explanation
Correct Option :D.
4. Git command that lets you get and set configuration variables that control all aspects of how Git looks and operates is
A. git config
B. git --version
C. git init
Explanation
Correct Option :A.
5. Which of the following is correct git command to set your username during git initial setup?
Explanation
Correct Option :A.
6. Git command to list all the settings Git can find at any point of time is
A. git config
C. git --list
Explanation
Correct Option :D.
7. To get the comprehensive manual page (manpage) help for any of the Git commands we can use
A. git help
B. git --help
C. man git-
Explanation
Correct Option :D.
8. Git command that helps us initialize git repository for the project (folder) that we intend to track using version control
system Git is
A. git config
B. git init
C. git add .
Explanation
Correct Option :B.
Git MCQ Set 2
1. Which of the following is example of distributed version control?
A. Git
B. Mercurial
C. SVN
D. Both A & B
Explanation
Correct Option :D.
A. Dennis Ritchie
B. Linus Torvalds
C. Linus Babbage
D. James Gosling
Explanation
Correct Option :B.
3. Which of the following are the stages in which your git file can reside?
A. modified
B. staged
C. committed
Explanation
Correct Option :D.
4. Git command that lets you get and set configuration variables that control all aspects of how Git looks and operates is
A. git config
B. git --version
C. git init
Explanation
Correct Option :A.
5. Which of the following is correct git command to set your username during git initial setup?
Explanation
Correct Option :A.
6. Git command to list all the settings Git can find at any point of time is
A. git config
C. git --list
Explanation
Correct Option :D.
7. To get the comprehensive manual page (manpage) help for any of the Git commands we can use
A. git help
B. git --help
C. man git-
Explanation
Correct Option :D.
8. Git command that helps us initialize git repository for the project (folder) that we intend to track using version control
system Git is
A. git config
B. git init
C. git add .
Explanation
Correct Option :B.
GIT Interview Questions
1) What is GIT?
Git is an open source distributed version control system and source code management (SCM) system with
an insistence to control small and large projects with speed and efficiency.
Git uses 'C' language. Git is quick, and 'C' language makes this possible by decreasing the overhead of run
times contained with high-level languages.
A repository consists of a list named .git, where git holds all of its metadata for the catalog. The content of
the .git file is private to Git.
A "bare" repository in Git includes the version control information and no working files (no tree), and it
doesn?t include the special. git sub-directory. Instead, it consists of all the contents of the .git sub-
directory directly in the main directory itself, whereas working list comprises of:
43.5M
955
1. A .git subdirectory with all the Git associated revision history of your repo.
2. A working tree, or find out copies of your project files.
GIT stash takes the present state of the working file and index and puts in on the stack for next and gives
you back a clean working file. So in case if you are in the middle of object and require to jump over to the
other task, and at the same time you don't want to lose your current edits, you can use GIT stash.
6) What is GIT stash drop?
When you are done with the stashed element or want to delete it from the directory, run the git 'stash
drop' command. It will delete the last added stash item by default, and it can also remove a specific topic
if you include as an argument.
With the help of branching, you can keep your branch, and you can also jump between the different
branches. You can go to your past work while at the same time keeping your recent work intact.
The 'Git config' is a great method to configure your choice for the Git installation. Using this command,
you can describe the repository behavior, preferences, and user information.
11) What is the definition of "Index" or "Staging Area" in GIT?
When you are making the commits, you can make innovation to it, format it and review it in the common
area known as 'Staging Area' or 'Index'.
A 'conflict' appears when the commit that has to be combined has some change in one place, and the
current act also has a change at the same place. Git will not be easy to predict which change should take
precedence.
13) What is the difference between git pull and git fetch?
Git pull command pulls innovation or commits from a specific branch from your central repository and
updates your object branch in your local repository.
Git fetch is also used for the same objective, but it works in a slightly different method. When you behave
a git fetch, it pulls all new commits from the desired branch and saves it in a new branch in your local
repository. If you need to reflect these changes in your target branch, git fetch should be followed with a
git merge. Your target branch will only be restored after combining the target branch and fetched branch.
To make it simple for you, remember the equation below:
If you need to resolve a conflict in Git, edit the list for fixing the different changes, and then you can run
"git add" to add the resolved directory, and after that, you can run the 'git commit' for committing the
repaired merge.
The git clone command generates a copy of a current Git repository. To get the copy of a central
repository, 'cloning' is the simplest way used by programmers.
16) What is git pull origin?
pull is a get and a consolidation. 'git pull origin master' brings submits from the master branch of the
source remote (into the local origin/master branch), and then it combines origin/master into the branch
you currently have looked out.
Git commits "records changes to the storehouse" while git push " updates remote refs along with
contained objects" So the first one is used in a network with your local repository, while the latter one is
used to communicate with a remote repository.
GIT is an open source version control framework; it will enable you to run 'adaptations' of a task, which
demonstrate the changes that were made to the code over time also it allows you keep the backtrack if
vital and fix those changes. Multiple developers can check out, and transfer changes, and each change can
then be attributed to a particular developer.
Commit message is a component of git which shows up when you submit a change. Git gives you a
content tool where you can enter the adjustments made to a commit.
1. The correct activity will devastate the express that was recently saved in a commit. If only the
commit message gets changed, that's not a problem. But if the contents are being modified,
chances of excluding something important remains more.
2. Abusing "git commit- amends" can cause a small commit to increase and acquire inappropriate
changes.
21) What does 'hooks' comprise of in Git?
This index comprises of Shell contents which are enacted after running the relating git commands. For
instance, Git will attempt to execute the post-commit content after you run a commit.
A) Git is a correction control framework, a tool to deal with your source code history.
GitHub is a website where you can transfer a duplicate of your Git archive. It is a Git repository hosting
service, which offers the majority of the distributed update control and source code management (SCM)
usefulness of Git just as including its features.
23) In Git, how would you return a commit that has just been pushed and made
open?
There can be two answers to this question and ensure that you incorporate both because any of the
below choices can be utilized relying upon the circumstance:
Remove or fix the bad document in another commit and push it to the remote repository. This is a unique
approach to correct a mistake. Once you have necessary changes to the record, commit it to the remote
repository for that I will utilize
Make another commit that fixes all changes that were made in the terrible commit. to do this, I will utilize
a command
Commit item contains the following parts; you should specify all the three present below:
An SHAI name, a 40 character string that uniquely distinguishes the commit object.
25) Describing branching systems you have utilized?
This question is a challenge to test your branching knowledge with Git along these lines, inform them
regarding how you have utilized branching in your past activity and what reason does it serves, you can
refer the below mention points:
Feature Branching:
A component branch model keeps the majority of the changes for a specific element within a branch. At
the point when the item is throughout tested and approved by automated tests, the branch is then
converged into master.
Task Branching
In this model, each assignment is actualized on its branch with the undertaking key included in the branch
name. It is anything but difficult to see which code actualizes which task, search for the task key in the
branch name.
Release Branching
Once the create branch has procured enough features for a discharge, you can clone that branch to frame
a Release branch. Making this branch begins the following discharge cycle so that no new features can be
included after this point, just bug fixes, documentation age, and other release oriented assignments ought
to go in this branch. When it is prepared to deliver, the release gets converged into master and labeled
with a form number. Likewise, it should be converged once again into creating a branch, which may have
advanced since the release was started.
At last, disclose to them that branching methodologies fluctuate starting with one association then onto
the next, so I realize essential branching activities like delete, merge, checking out a branch, etc.
26) By what method will you know in Git if a branch has just been combined into
master?
To know whether a branch has been merged into master or not you can utilize the below commands:
git branch - merged It records the branches that have been merged into the present branch.
git branch - no merged It records the branches that have not been merged.
27) How might you fix a messed up submit?
To fix any messed up commit, you will utilize the order "git commit?correct." By running this direction, you
can set the wrecked commit message in the editor.
o Pikacode
o Visual Studio Online
o GitHub
o GitEnterprise
o SourceForge.net
29) Mention some of the best graphical GIT customers for LINUX?
a. Git Cola
b. Smart git
c. Git-g
d. Git GUI
e. Giggle
f. qGit
'Subgit' is a tool that migrates SVN to Git. It is a stable and stress-free migration. Subgit is one of the
solutions for a company-wide migration from SVN to Git that is:
Git Commands
git config
Usage: git config –global user.name “[name]”
Usage: git config –global user.email “[email address]”
This command sets the author name and email address respectively to be used with your
commits.
git init
Usage: git init [repository name]
This command is used to start a new repository.
git clone
Usage: git clone [url]
This command is used to obtain a repository from an existing URL.
git add
Usage: git add [file]
This command adds a file to the staging area.
git commit
Usage: git commit -m “[ Type in the commit message]”
This command records or snapshots the file permanently in the version history.
git diff
Usage: git diff
This command shows the file differences which are not yet staged.
git reset
Usage: git reset [file]
This command unstages the file, but it preserves the file contents.
Usage: git reset –hard [commit] This command discards all history and goes back to the
specified commit.
git status
Usage: git status
This command lists all the files that have to be committed.
git rm
Usage: git rm [file]
This command deletes the file from your working directory and stages the deletion.
git log
Usage: git log
This command is used to list the version history for the current branch.
git branch
Usage: git branch
This command lists all the local branches in the current repository.
Usage: git branch [branch name]
This command creates a new branch.
git checkout
Usage: git checkout [branch name]
This command is used to switch from one branch to another.
git merge
Usage: git merge [branch name]
This command merges the specified branch’s history into the current branch.
git remote
Usage: git remote add [variable name] [Remote Server Link]
This command is used to connect your local repository to the remote server.
git push
Usage: git push [variable name] master
This command sends the committed changes of master branch to your remote repository.
git pull
Usage: git pull [Repository Link]
This command fetches and merges changes on the remote server to your working
directory.
git stash
Usage: git stash save
This command temporarily stores all the modified tracked files.