Q#1. What is GIT?
Ans. GIT is a distributed version control system and source code management (SCM) system with an emphasis to handle small and large projects with speed and efficiency.
Q#2. What is the command to write a commit message in Git?
Ans. Answer to this is pretty straightforward.
Command that is used to write a commit message is “git commit -a”.
Now explain about -a flag by saying -a on the command line instructs git to commit the new content of all tracked files that have been modified. Also mention you can use “git add<file>” before git commit -a if new files need to be committed for the first time.
Q#3. What is a repository in GIT?
Ans. A repository contains a directory named .git, where git keeps all of its metadata for the repository. The content of the .git directory are private to git.
Q#4. What is ‘bare repository’ in Git?
Ans. You are expected to tell the difference between a “working directory” and “bare repository”.
A “bare” repository in Git just contains the version control information and no working files (no tree) and it doesn’t contain the special .git sub-directory. Instead, it contains all the contents of the .git sub-directory directly in the main directory itself, where as working directory consist of:
A .git subdirectory with all the Git related revision history of your repo.
A working tree, or checked out copies of your project files.
Q#5. What is the difference between GIT and SVN?
Ans. The difference between GIT and SVN is
a) Git is less preferred for handling extremely large files or frequently changing binary files while SVN can handle multiple projects stored in the same repository.
b) GIT does not support ‘commits’ across multiple branches or tags. Subversion allows the creation of folders at any location in the repository layout.
c) Gits are unchangeable, while Subversion allows committers to treat a tag as a branch and to create multiple revisions under a tag root.
Q#6. What language is used in Git?
Ans. Instead of just telling the name of the language, you need to tell the reason for using it as well. I will suggest you to answer this by saying:
Git uses ‘C’ language. GIT is fast, and ‘C’ language makes this possible by reducing the overhead of run times associated with high level languages.
Q#7. What are the advantages of using GIT?
Ans. a) Data redundancy and replication
b) High availability
c) Only one.git directory per repository
d) Superior disk utilization and network performance
e) Collaboration friendly
f) Any sort of projects can use GIT
Q#8. In Git how do you revert a commit that has already been pushed and made public?
Ans. There can be two answers to this question and make sure that you include both because any of the below options can be used depending on the situation:
Remove or fix the bad file in a new commit and push it to the remote repository. This is the most natural way to fix an error. Once you have made necessary changes to the file, commit it to the remote repository for that I will use
git commit -m “commit message”
Create a new commit that undoes all changes that were made in the bad commit.to do this I will use a command
git revert <name of bad commit>
Q#9. What is the function of ‘GIT PUSH’ in GIT?
Ans. GIT PUSH’ updates remote refs along with associated objects.
Q#10. What is the difference between git pull and git fetch?
Ans. Git pull command pulls new changes or commits from a particular branch from your central repository and updates your target branch in your local repository.
Git fetch is also used for the same purpose but it works in a slightly different way. When you perform a git fetch, it pulls all new commits from the desired branch and stores it in a new branch in your local repository. If you want to reflect these changes in your target branch, git fetch must be followed with a git merge. Your target branch will only be updated after merging the target branch and fetched branch. Just to make it easy for you, remember the equation below:
Git pull = git fetch + git merge