Git Interview Questions

Git Exam Questions and answers

Which of the following should be done after installing Git on a system for the first time? (Choose all that apply)

– git config –global “”
– git config –global
Which Git command is used to stage changes for a commit?
– git add is used to stage changes for a commit.
What command is used to get changes into a remote repo?
– git push

What does the git checkout feature1 command do?
– It checks out a branch called feature1.

Git is an example of what type of tool?
– Source Control Management (SCM)
What is one way to configure a Git installation to authenticate with a remote repository like
– Upload a public ssh key to your account.

Which command is used to obtain a local copy of a Git repository?
– git clone

Git Status, Git Commit, Git Add

To Edit File in Git

cd to directory: vi views/index.jade (File Name)
Edit the file in VI Editor and save :qw!

To see Status: git status

# On branch master
# Changes to be committed:
# (use “git reset HEAD <file>…” to unstage)
# modified: views/index.jade

To Commit

git commit -m “change header text

[master 43185e0] change header text
1 file changed, 2 insertions(+), 2 deletions(-)


Setting up Priate Key Access

Setting up Priate Key Access\

An easy way to authenticate with remote git server like GitHub is to use an ssh key pair.

On a CentOs environment, you can generate an ssh key pair like this
ssh-keygen -t rsa -b 4096

Setting up Priate Key Access

After generating the key pair, copy the contents of ~/.ssh/

[root@aryan-34252e5f2 ~]# ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
SHA256:mTVGOKHkJ7uWbiDVtm0cecEJfTEH53g1mnu8VsPnif4 root@aryan-34252e5f2.mylabserver.c om
The key’s randomart image is:
+—[RSA 4096]—-+
| . o*..+oo..|
| o .o.= .*o..|
| .+ .o+o.oo |
| . o+o=.. .+ |
| . ..+So . =o|
| . . .o+ o.*|
| . .+. . +.|
| o. . . |
| .. ..E |

Configure Your Name and Email in GIT

Configure Your Name and Email

After Installing git, you need to set the name and email that will be associated with your commits. When using GitHub, it is best to use an email address that is associated with your GitHub account

git config –”<your name>”
git config –global<your email>


How to verify Git version

git –version