Top 50 Git Interview Questions with Answers

Git Interview Questions with Answers
  1. What is Git?
    a. A version control system
    b. A programming language
    c. A software suite
    d. An operating system

Answer: a

  1. Who developed Git?
    a. Linus Torvalds
    b. Richard Stallman
    c. Bill Gates
    d. Steve Jobs

Answer: a

  1. What is a repository?
    a. A location where code is stored
    b. A person who manages code
    c. A type of code
    d. A software program

Answer: a

  1. What is a branch?
    a. A separate version of the code
    b. A type of commit message
    c. A way to share code with others
    d. A type of tag

Answer: a

  1. What is a commit?
    a. A change made to the code
    b. A type of pull request
    c. A way to merge code
    d. A feature request

Answer: a

  1. What is a pull request?
    a. A way to propose changes to the code
    b. A way to revert changes
    c. A way to merge changes
    d. A way to delete code

Answer: a

  1. What is a merge conflict?
    a. A problem that occurs when two or more people make changes to the same code
    b. A type of error
    c. A type of commit message
    d. A way to share code with others

Answer: a

  1. What is a tag?
    a. A way to mark a specific point in the code’s history
    b. A type of commit message
    c. A way to merge code
    d. A way to delete code

Answer: a

  1. What is a stash?
    a. A way to save changes without committing them
    b. A way to delete code
    c. A way to revert changes
    d. A way to share code with others

Answer: a

  1. What is a remote?
    a. A separate repository that is not on the local machine
    b. A person who manages code
    c. A type of code
    d. A software program

Answer: a

  1. What is the difference between git clone and git fork?
    a. Git clone makes a copy of the repository on your local machine, while git fork creates a copy on GitHub/GitLab.
    b. Git clone creates a copy of the repository on GitHub, while git fork creates a copy on your local machine.
    c. Git clone and git fork both do the same thing.
    d. Git clone creates a new branch, while git fork creates a new repository.

Answer: a

  1. What is the command to initialize a new Git repository?
    a. git init
    b. git clone
    c. git pull
    d. git push

Answer: a

  1. What is the command to add a file to the staging area?
    a. git add filename
    b. git commit
    c. git push
    d. git pull

Answer: a

  1. What is the command to commit changes?
    a. git commit -m “commit message”
    b. git add filename
    c. git push
    d. git pull

Answer: a

  1. What is the command to push changes to a remote repository?
    a. git push
    b. git pull
    c. git add filename
    d. git commit -m “commit message”

Answer: a

  1. What is the command to create a new branch?
    a. git branch new_branch_name
    b. git checkout new_branch_name
    c. git merge new_branch_name
    d. git clone new_branch_name

Answer: a

  1. What is the command to switch to a different branch?
    a. git checkout branch_name
    b. git branch new_branch_name
    c. git merge branch_name
    d. git clone branch_name

Answer: a

  1. What is the command to merge one branch into another?
    a. git merge branch_name
    b. git clone branch_name
    c. git add filename
    d. git push

Answer: a

  1. What is the command to view the commit history?
    a. git log
    b. git branch
    c. git clone
    d. git commit

Answer: a

  1. What is the command to revert changes?
    a. git revert
    b. git reset
    c. git checkout
    d. git pull

Answer: a

  1. What is the command to undo the last commit?
    a. git reset HEAD~1
    b. git revert HEAD~1
    c. git checkout HEAD~1
    d. git commit –amend

Answer: a

  1. What is the difference between git pull and git fetch?
    a. Git pull fetches changes and merges them, while git fetch only fetches changes.
    b. Git pull only fetches changes, while git fetch fetches and merges changes.
    c. Git pull and git fetch do the same thing.
    d. Git pull and git fetch are not actual Git commands.

Answer: a

  1. What is the command to view the changes made to a file?
    a. git diff filename
    b. git log
    c. git branch
    d. git clone

Answer: a

  1. What is the command to create a tag?
    a. git tag tag_name
    b. git push
    c. git pull
    d. git add filename

Answer: a

  1. What is the command to delete a branch?
    a. git branch -d branch_name
    b. git clone branch_name
    c. git add filename
    d. git commit -m “commit message”

Answer: a

  1. What is the command to view the status of the repository?
    a. git status
    b. git log
    c. git branch
    d. git clone

Answer: a

  1. What is the command to view the remote repositories?
    a. git remote -v
    b. git clone
    c. git add filename
    d. git commit -m “commit message”

Answer: a

  1. What is the command to rename a file?
    a. git mv old_filename new_filename
    b. git add filename
    c. git commit -m “commit message”
    d. git push

Answer: a

  1. What is the command to undo changes made to the staging area?
    a. git reset filename
    b. git add filename
    c. git commit -m “commit message”
    d. git push

Answer: a

  1. What is the command to view the changes made to the repository?
    a. git diff
    b. git log
    c. git branch
    d. git clone

Answer: a

  1. What is the command to view the list of remote branches?
    a. git branch -r
    b. git log
    c. git status
    d. git clone

Answer: a

  1. What is the command to fetch changes from a remote repository?
    a. git fetch
    b. git pull
    c. git push
    d. git clone

Answer: a

  1. What is the command to view the list of tags?
    a. git tag
    b. git branch
    c. git log
    d. git clone

Answer: a

  1. What is the command to view the difference between two branches?
    a. git diff branch_1..branch_2
    b. git merge branch_1 branch_2
    c. git pull branch_1 branch_2
    d. git push branch_1 branch_2

Answer: a

  1. What is the command to move a commit from one branch to another?
    a. git cherry-pick commit_hash
    b. git merge branch_1 branch_2
    c. git checkout branch_name
    d. git push

Answer: a

  1. What is the command to rebase a branch?
    a. git rebase branch_name
    b. git merge branch_name
    c. git add filename
    d. git push

Answer: a

  1. What is the command to view the current branch?
    a. git branch
    b. git clone
    c. git log
    d. git status

Answer: a

  1. What is the command to view the list of commits for a specific file?
    a. git log filename
    b. git branch
    c. git checkout
    d. git push

Answer: a

  1. What is the command to undo changes to a specific file?
    a. git checkout filename
    b. git reset filename
    c. git add filename
    d. git push

Answer: a

  1. What is the command to delete a tag?
    a. git tag -d tag_name
    b. git push
    c. git pull
    d. git add filename

Answer: a

  1. What is the command to change the commit message?
    a. git commit –amend
    b. git reset
    c. git revert
    d. git push

Answer: a

  1. What is the command to delete untracked files?
    a. git clean -f
    b. git reset
    c. git revert
    d. git add filename

Answer: a

  1. What is the command to set up a Git repository with a remote?
    a. git remote add remote_name remote_url
    b. git push
    c. git pull
    d. git add filename

Answer: a

  1. What is the command to add multiple files to the staging area?
    a. git add .
    b. git add *
    c. git add filename1 filename2
    d. git add -a

Answer: a

  1. What is the command to view the list of contributors to the repository?
    a. git shortlog
    b. git branch
    c. git log
    d. git clone

Answer: a

  1. What is the command to view the version number of Git?
    a. git –version
    b. git version
    c. git branch
    d. git clone

Answer: a

  1. What is the command to discard changes made to a file?
    a. git checkout filename
    b. git reset filename
    c. git add filename
    d. git push

Answer: a

  1. What is the command to view the list of files in the working directory?
    a. ls
    b. git ls
    c. git list
    d. git dir

Answer: a

  1. What is the command to discard changes made to the entire repository?
    a. git reset –hard
    b. git revert
    c. git add .
    d. git push

Answer: a

  1. What is the command to stash changes without committing them?
    a. git stash
    b. git reset
    c. git revert
    d. git push

Answer: a

Good GIT SCM Video at youtube.

rajeshkumar created the topic: Good GIT SCM Video at youtube.
Hi Friends,

This week I am started digging more into to GIT. I hope these videos will be helpful for you as well.

Introduction to Git

Linus Torvalds on git

O’Reilly Webcast: Git in One Hour

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Good PPT slides for GIT on slideshare.net

rajeshkumar created the topic: Good PPT slides for GIT on slideshare.net
Must be referenced.

www.slideshare.net/JamesEdwardGrayII/git-and-github-3675432
www.slideshare.net/terrywang/git-101-tutorial-presentation/
www.slideshare.net/railsconf/smacking-gi…advanced-git-tricks/

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Useful website Reference for GIT

rajeshkumar created the topic: Useful website Reference for GIT
Here are following website good to know more about GIT-SCM.

help.github.com/
progit.org/
git-scm.com/
whygitisbetterthanx.com/

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

Urgent requirement for ‘IBM RTC with SCRUM Master’ with our client

ranjita created the topic: Urgent requirement for ‘IBM RTC with SCRUM Master’ with our client
Hi,
Greetings for the Day!!
We have urgent openings for” SCM with Scrum Master” with our client.
Location: Hyderabad
Mode:7+Yrs
JD:
Methods-4+ years:
Scrum
Extreme Programming (XP)
Test Driven Development (TDD)
Continuous Delivery (CD)
Acceptance Test Drive Development (ATDD)

Tools-2+ years:
Rational Team Concert (RTC)
Rational Quality Manager (RQM)
If interested reach me@vasavi@qcadd.com
Note: we will consider 15 Days of notice period only plzzz
It would be appreciated if any one can provide references

Regards,
Vasavi.A
9959188581
Regards,
Vasavi
Recruitments | Q-CAD Private Limited,
Web: www.qcadd.com
Report This
Quick Reply Action Moderate Thank You

Tagged :

This user is in an organization and can’t be deleted.

scmuser created the topic: This user is in an organization and can’t be deleted.
Following error while deleting users from git gub.

This user is in an organization and can’t be deleted.

any solution?

Tagged :

GitLab is not responding

rajeshkumar created the topic: GitLab is not responding
Issues –
After setting up the gitlab in ubantu by following www.scmgalaxy.com/111-git/888-setting-up…n-local-machine.html

I am getting error called “GitLab is not responding” on front page.

Followup –

I did run status commands and got following output…

sudo gitlab-ctl status
run: nginx: (pid 12728) 165s; run: log: (pid 12574) 372s
run: postgresql: (pid 12731) 165s; run: log: (pid 12485) 421s
run: redis: (pid 12741) 165s; run: log: (pid 12402) 427s
run: sidekiq: (pid 12744) 165s; run: log: (pid 12558) 378s
run: unicorn: (pid 12808) 28s; run: log: (pid 12546) 380s

I stop and restart the gitlab using…

sudo gitlab-ctl start
ok: run: nginx: (pid 12961) 0s
ok: run: postgresql: (pid 12964) 0s
ok: run: redis: (pid 12967) 0s
ok: run: sidekiq: (pid 12970) 0s
ok: run: unicorn: (pid 12983) 0s

Solution

I found out that some other services was running with port 80. I just stopped that services and re-startted the gitlab services and it went through..
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :

The ova package name does not match

rajeshkumar created the topic: the ova package name does not match
While importing github-enterprise-11.10.320-x86_64.ova in Vmware workstation 7, I am getting following error…
The ova package name does not match

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: the ova package name does not match
Downloaded a OVA file and tried to import it into my VMWare Workstation and if something can go wrong – it does.

“the ova package name does not match the ovf file inside it” was the error message, after some searching I found out that a OVA is nothing else than a compressed tar file with another ending but includes the OVF and VHD files.

Usind 7-zip to look into it I found the name of the OVF and renamed the OVA to the same name – voila – it works
Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

rajeshkumar replied the topic: the ova package name does not match
Another way – enterprise.github.com/help/articles/gett…rted-with-virtualbox

Regards,
Rajesh Kumar
Twitt me @ twitter.com/RajeshKumarIn

Tagged :