[MOST FREQUENTLY ASK] GIT Interview Questions & Answers

[MOST FREQUENTLY ASK] GIT Interview Questions & Answers

Last updated on 15th Jun 2020, Blog, Interview Questions

About author

Ramya (Sr Technical Director )

Highly Expertise in Respective Industry Domain with 6+ Years of Experience Also, She is a Technical Blog Writer for Past 2 Years to Renders A Kind Of Informative Knowledge for JOB Seeker

(5.0) | 16547 Ratings 738

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

1. What is a .git Directory?


The moment you create a repository, you will find a .git directory present inside it. This .git directory contains all the metadata of the repository and maintains a track of all the changes made to the files in your repository, by keeping a commit history.

All the information regarding commits, hooks, refs, object databases, remote repository addresses, etc. are kept inside this folder. This is the most crucial part of Git. When you clone any Git repository on your local machine, this .git is the directory that actually gets copied.

2. What is the command you can use to write a required message?


git commit –m, “m”is our message”.

3. What is the variance between GIT and SVN?



  • Git is a circulated VCS; .
  • Git has a brought together server and store,
  • The content in Git is put away as metadata,
  • Git branches are simpler to work with than SVN branch


  • SVN is a non-appropriated VCS
  • SVN does not have a unified server or store
  • SVN stores documents of substance

4. What are the benefits of using GIT?


One of the greatest focal points of Git is its fanning abilities. Not at all like incorporated adaptation control frameworks, Git branches are modest and simple to combine. This encourages the component branch work process prevalent with numerous Git clients. Highlight branches give a confined domain to each change to your code base.

5. What is Git fork? What is the difference between fork, branch and clone?


  • A fork is a remote, server-side copy of a repository, distinct from the original. A fork isn’t a Git concept really, it’s more a political/social idea.
  • A clone is not a fork; a clone is a local copy of some remote repository. When you clone, you are actually copying the entire source repository, including all the history and branches.
  • A branch is a mechanism to handle the changes within a single repository in order to eventually merge them with the rest of code. A branch is something that is within a repository. Conceptually, it represents a thread of development.

6. What is the meaning of ‘GIT PUSH’ in GIT?


Git gives you a ton of approaches to allude to a commit however for most purposes you’ll simply utilize the name of a branch with git push

7. Why is GIT better than Subversion?


Designers like Git on account of its successful spreading model. In Git, branches are just references to a certain commit, making them lightweight yet ground-breaking. Git enables you to create, erase, and change a branch whenever without influencing the commits

8. What is the Production Area or Index in GIT?


The git “index” is the place you place documents you need committed to the git vault. The index is otherwise called store, registry reserve, current catalog reserve, organizing territory, and arranged documents. Before you “commit” (checkin. records to the git storehouse, you have to initially put the documents in the git “index”.

9. What is GIT stash?


Stashing takes the filthy condition of your working registry that is, our adjusted tracked documents and organized changes and spares it on a heap of incomplete changes that we can reapply whenever.

10. What is GIT stash drop?


Git stash is a transitory stockpiling. When you’re prepared to proceed with the last known point of interest, you can reestablish the spared state effectively: git stash pop . Popping your reserve expels the progressions from your reserve and reapplies the last spared state.

11. Name a few Git repository hosting services


  • GitHub
  • Pika Code
  • Visual Studio Online
  • GitEnterprise
  • net

12. What is the function of git clone?


git clone is a Git direction line utility which is utilized to focus on a current archive and make a clone, or duplicate of the objective vault.

13. What is the function of ‘git config’?


The git config direction is a comfort work that is utilized to set Git setup esteems on a worldwide or neighborhood venture level. These design levels relate to .git config content documents. Executing git config will alter an arrangement content document.

14. What does the commit object contain?


The commit object contains the index tree object hash, parent commit hash, creator, committer, date and message.

15. How can you make a repository in Git?


In Git, to generate a repository, create a directory for the project if it does not exist, and then run command git init. By running this command . git directory will be generated in the project directory, the directory does not need to be empty.

16. What is head in git and how many heads can be generated in a repository?


There can be any number of heads in a GIT vault. As a matter of course there is one head known as HEAD in every store in GIT

17. How do resolve merge conflicts?


  • Open Terminal Git Bash the terminal.
  • Navigate into the local Git archive that has the consolidation conflict.
  • Produce a rundown of the records influenced by the consolidation conflict.
  • Open your preferred content tool, for example, Atom, and navigate to the record that has consolidated conflicts.

18. How do we push a branch to github?


Make another branch: git checkout – b feature_branch_name.

Alter, include and submit your records.

Push your branch to the remote repository: git push – u source feature_branch_name.

19. What is Release Branch in Git


The master and develop branches structure the base of any vault in Git. The master branch contains a version of the code that is underway, and the develop branch contains a version that is expected to be discharged in a forthcoming version.

20. What is a conflict in git?


Merge conflicts happen when you merge branches that have contending commits, and Git needs your assistance to choose which changes to fuse in the last merge.Usually, the progressions are on various lines, or even in various documents, which makes the merge basic for PCs to get it.

    Subscribe For Free Demo

    21. How can conflict in git be resolved?


    Conflicts for the most part emerge when two individuals have changed similar lines in a document, or in the event that one designer erased a record while another engineer was altering it. … Git will check the document as being tangled and end the blending procedure. It is then the designers’ duty to determine the contention.

    22. How to remove a file from Git Tracking ?



    We need to remove it from your tracked records (all the more precisely, remove it from your arranging territory) and afterward submit. The git rm order does that, and furthermore removes the document from your working catalog so you don’t consider it to be an untracked record whenever around.

    23. What is an alternative option for merging in git?


    Git rebase is the alternate option for merging in Git

    24. What is the syntax for Rebase in git ?


    git rebase [-i | –interactive] [] [–exec ] [–onto ][ []]

    25. What is the variance between git remote and git clone?


    The main difference between git clone and git remote is that git clone is utilized to make another nearby repository while git remote is utilized in a current repository.

    26. What is GIT version control / Benefits of Version Control ?


    Version control systems are a classification of programming apparatuses that assistance a product group oversee changes to source code after some time. Version control programming monitors each adjustment to the code in an uncommon sort of database. In the event that an oversight is made, designers can look to better days and contrast prior versions of the code with assistance to fix the misstep while limiting disturbance to all colleagues.

    27. What is Sub git?


    ‘Subgit’ is a device for a smooth, tranquil SVN to Git movement. Subgit is an answer for an organization – wide movement from SVN to Git that is:

    28. Why to use Subgit?


    It is vastly improved than git svn

    No prerequisite to change the foundation that is as of now put

    Allows to utilize all git and all sub adaptation highlights

    Provides authentic tranquil relocation experience.

    29. What is the meaning of git different in git?


    Git (/ɡɪt/) is a circulated adaptation control framework for following changes in source code amid programming advancement. … Git was made by Linus Torvalds in 2005 for improvement of the Linux part, with other portion engineers adding to its underlying advancement.

    30. What is git status used for?


    git status. The git status order shows the condition of the working registry and the organizing region. It gives you a chance to see which changes have been arranged, which haven’t, and which documents aren’t being followed by Git.

    Course Curriculum

    Best Hands-on Practical Git Training By Top-Rated Instructors

    • Instructor-led Sessions
    • Real-life Case Studies
    • Assignments
    Explore Curriculum

    31. What is the variance between the git diff and git status’?


    Distinction between git status and git diff

    Git diff direction will demonstrate to you the careful distinction, or state in the event that you added a few lines to a document, it will demonstrate to you those lines which are altered. A straightforward “git diff” direction will reveal to you the distinction between what’s your present condition of the documents, and the condition of the records in organizing zone

    32. What is the meaning of git checkout in git?


    In Git terms, a “checkout” is the demonstration of exchanging between various adaptations of an objective element. The git checkout direction works upon three particular substances: records, submits, and branches.

    33. What is the function of git rm?


    The essential capacity of git rm is to expel followed documents from the Git list. Furthermore, git rm can be utilized to expel documents from both the arranging file and the working index.

    34. What does the meaning of git stash apply?


    git stash briefly retires (or stashes. transforms you’ve made to your working duplicate so you can take a shot at something different, and after that return and re-apply them later on.

    35. What is the use of git log?


    Git logs enable you to audit and peruse a background marked by everything that happens to a vault. The history is constructed utilizing git-log , a basic apparatus with a huge amount of alternatives for showing submit history.

    36. What is git add is used for?


    At the point when utilized without anyone else, git include will advance pending changes from the working catalog to the arranging territory. The git status order is utilized to analyze the present condition of the vault and can be utilized to affirm a git include advancement.

    37. What is the meaning of git reset?


    It resets the record, yet not the work tree. This implies every one of your records are flawless, however any contrasts between the first submit and the one you reset to will appear as neighborhood adjustments (or unmanaged documents. with git status.

    38. What is git Is-tree?


    The Working Tree in Git is a catalog (and its records and subdirectories. on your document framework that is related with a vault. … When you open the records for a task that is being overseen as a Git archive then you are getting to the Working Tree.

    39. How is git instaweb used?


    The internet browser that ought to be utilized to see the gitweb page. This will be passed to the git web{littd}browse aide content alongside the URL of the gitweb.

    40. What does ‘hooks’ consist of in git?


    Git hooks are contents that Git executed previously or after occasions, for example, submit, push, and get. Git snares are a work in highlight – no compelling reason to download anything. Git hooks are run locally. These hooks’ contents are just restricted by an engineer’s creative ability.

    41. Explain what the commit message is?


    We will in general pound the subject of a submit message with the body: Writing a subject of a submit together with the body of that submit message is the incorrect approach. When you see your submit message is getting too long to even think about explaining this implies submit is doing such a large number of things separate it

    42. How can you fix a broken commit?


    fixing broken submit messages. submitted 12 Jan 2009. You recently dedicated that marvelous component/test/bug, however something simply isn’t right. Either some…

    43. Why is it advisable to create an added commit rather than amending an existing commit?


    “git commit amend” in reality just influences increments to the past to commit, so you can organize documents .. We’ve included this in JIRA as a component demand here: … Still adequate for me, I’m authoritatively prepared to change to SourceTree with the two feet!

    44. What is ‘bare repository’ in GIT?


    An exposed Git repository is commonly utilized as a Remote Repository that is sharing a repository among a few unique individuals. You don’t do work directly inside the remote repository so there’s no Working Tree (the documents in your project that you alter., simply uncovered repository information.

    45. What is the use of the Version Control System?


    Version Control System can be defined as a software which allows several developers to work simultaneously and also keeps the entire history of the tasks performed. This software won’t allow developers to overwrite other people’s work. There are two types of version control systems available:

    • Distributed or Decentralized Version Control System
    • Centralized Version Control system.

    46. Explain a centralized version control system and state its disadvantages.


    CVCS or Centralized Version Control System allows a centralized server to save files in it and allows access to several people. The main advantage of CVCS is, it allows the whole team to communicate at a time on a centralized server. But, CVCS fails with the central server. If the centralized server shuts down for a period of time, communication to the central server completely stops. Sometimes, there is a risk of data loss and through which the data stored in the central server may get lost. This happens because of the corrupted drive in the central server.

    47. Explain Distributed version control system.


    DVCS overcomes the disadvantages of CVCS. This system allows its clients to take snapshots of the current directory. It also saves a duplicate copy (mirror. in the repository. Because of this feature, a client can restore his data though the server is down.

    48. Name some Basic Operations in Git.


    Some basic operation in Git include:

    • Initialize
    • Add
    • Commit
    • Push
    • Pull

    49. Name some Advanced Operations in Git.


    Some advanced operations in Git are:

    • Branching
    • Merging
    • Rebasing

    50. What is ‘Local Repository’ in GIT?


    Generally version control software contains a separate working space. In that space, developers modify the scripts. Once they finalize, that will be stored in the repository.  GIT tool provides a replica copy of the entire repository. Developers can make changes as per their requirement in that repository itself. They can add a file, rename a file, delete a file, move a file, make modifications etc.,

    Course Curriculum

    Learn In-Depth Knowledge on Git Course to Get Best JOBs in Top MNCs

    Weekday / Weekend BatchesSee Batch Details

    51. How do you define a ‘conflict’ in git?


    If you want to merge a commit there is a change in one place and same change already exists then while merging the Git will not be able to predict which is the change that needs to be taken precedence.

    52. Explain the basic workflow of GIT.


    The basic workflow of GIT can be divided into three steps. They are:

    • User can alter a file from the current directory
    • User can add those files into the staging area

    Users can do commit operations. Commit transfers files from staging. A ‘Push’ saves the changes in the GIT repository permanently.

    53. What do you mean by ‘blobs’?


    Blob refers to Binary Large Object.  In GIT, every version of a file is called a blob. Generally, a blob will contain file data whereas it will not store any metadata about a particular file. Simply, blob is a binary file. In the DB of Git, blob is named as SHA1(Secured hash function. hash of that particular file. Generally, GIT won’t address its files by names whereas they are content addressed.

    54. What is a tree in GIT?


    Tree refers to an object which means a directory. Tree keeps blobs and sub directories in it. A tree is nothing but a binary file which saves the references of blobs. A tree is a SHA1 hash of tree objects.

    55. Explain commit in GIT.


    Commit keeps the working state of the repository. A commit can also be named by the secure hash function, SHA1. A commit object can be considered as a node of the linked list. Each of this commit objects will contain a pointer to the parent commit object. To track the history of a commit object, we can look into the parent pointer to get the same. If a commit object contains several parent commits, that commit can be built by combining two branches together.

    56. What do you mean by branches in GIT?


    Branches were meant to build yet another line of development.  Git contains a master branch by default similar to trunk in subversion. Generally, branches were built to work on something new. Once the mean work is completed, that particular branch is merged to the master branch and that particular branch is deleted. Further, each branch is referenced by Head, which is a pointer that points to the current commit in the branch. If a user makes a commit, Head is upgraded with the current commit.

    57. What is the purpose of Tags?


    The purpose of tags is to allocate some meaningful name with a particular version present in the repository. Tags and branches look alike, but tags are permanent. So, tag is a branch but no one can make changes to it. If a user builds a tag for a specific commit, though he creates yet another commit, the same will not be updated. Developers generally build tags for product releases.

    58. Explain Clone operation in GIT.


    The purpose of clone operation is to build a specimen or a mirror of the repository. Clone verifies the current working copy and also creates a mirror of the entire repository. It allows users to perform various functions in the local repository. All these operations can be performed offline without even a network connection. But, if the user needs to sync the repository specimens, a network connection is required to perform synchronization.

    59. Explain Push operation in GIT.


    A ‘push’ copy the changes made from a local repository instance into a remote repository. This saves the changes into the Git repository permanently. A Push operation is similar to a commit operation in subversion.

    60. Explain Pull operation in GIT.


    A ‘pull’ copy the changes made from a remote repository to a local repository. Generally, if we need to synchronize between two repository instances, pull operation can be performed. A Pull operation is similar to an update in the subversion.

    61. What do you mean by ‘Head’?


    Head refers to a pointer which points to the current commit in the branch. If a user makes a commit, Head is upgraded with the current commit.

    62. What’s the difference between a “pull request” and a “branch”?


    • A branch is just a separate version of the code.
    • A pull request is when someone takes the repository, makes their own branch, does some changes, then tries to merge that branch in (put their changes in the other person’s code repository).

    63. What do you mean by revision in Git?


    Revision refers to the version of the source code which is written by a developer. Generally revisions in Git amount to commits. Users can identify the commits through the SHA1 secure hashes.

    64. What is an URL in the Git?


    URL in Git is used to save the config file and it represents the place where the Git repository is located.

    65. What is git config in Git?


    Git supports a tool to set configuration variables, called a git config tool. All the global configurations in .gitconfig file present in the current working directory or home directory is stored by Git. But, the user has to set the variables as global otherwise, by default it is stored in the local directory. For that, the user has to set the configuration parameters to global by adding the –global option.

    66. How do you install a Git client in a machine?


    The installation of Git client varies according to the corresponding linux platform you are using. The syntax varies between various linux platforms. For an instance, if the user uses RPM based Linux/GNU distribution, use yum command :

    • yum –y install git-core
    • If the user uses Debian based Linux/GNU distribution, use apt-get command as follows:
    • sudo apt-get install git-core
    • To identify the git version, you can check using:
    • git –version

    67. What is the first step to establish connection to Git?


    Like every setup, initialization is the first step to establish connection to Git. Once you finish the initialization of git, do push/pull source code. The command to initialize Git is:

    $git init

    68. What is the command to get the source code from Github?


    The command is:

    $git remote add origin git url

    $git pull origin repository name

    69. What is the command to clone github repository?


    The command is:

    git clone url  project-name/foldername  -b develop

    70. What do you mean by git bash?


    Git bash us a source controller which is used to save the source code developed by the developer.

    Git Sample Resumes! Download & Edit, Get Noticed by Top Employers! Download

    71. What is the command to check git status?


    The following is the command to check git status:

    $git status

    72. What is the command to make commits?


    The command to make commit is :

    $git commit -b “Commit description”

    This command will commit the files.

    73. How will you push the committed source code to the server?


    The command to push the committed source code to server is:

    git push -u origin master

    74. Write the syntax to do rebasing in Git.


    The syntax for rebasing is

    $ git rebase [new-commit]

    75. What is the use of Git instaweb?


    Git instaweb lets a web browser automatically and runs the web server through an interface to the user’s local repository.

    76. Explain the life cycle of Git.


    The life cycle of Git contains the following stages:

    • User has to clone the Git repository as a current/working copy.
    • Users can alter the current/working copy by editing/adding files.

    It is also possible to consider changes from other developers and the same can be updated.

    • Before committing, the user has to review the changes performed.
    • After review, commit. Later push the changes to the repository.
    • If suppose something goes wrong, make corrections to the last commit and then push that changes to the repository.

    77. How do you get a Git Repository?


    Git repository can be obtained in any of the following two ways:

    • Users can use a local directory which is not under version control that time. Convert that to a Git Repository.
    • Users can take an existing Git Repository and can clone it.

    Both these options will create a Git Repository in the user’s local machine.

    78. How do you view the commit history?


    After creating various commits or by cloning a repository using an existing commit history, users can check the commit history using git log command. Git hub contains simple examples in a basic project folder called ‘simple git’. You have to run the project using the command:

    • $git  clone https://github.com/schacon/simplegit-progit
    • $git log
    • The output could looks like this:
    • $git log
    • Commit dg56agghbx34987ahj4567845z67a4765az790dc43
    • Author:………………………………..
    • Date…………………………………..
    • Version  number changed
    • Commit 76545adgg745a564dg7421j45690xcz3679axcvbn6
    • Author:………………………………..
    • Date…………………………………..
    • Removed unwanted test
    • Commit 124adhkk468900afcjlll129kk480837adcv4689axny8
    • Author:………………………………..
    • Date…………………………………..
    • First commit

    The git log command lists the commands present in that repository in the reverse order by default. The most recent commit will be shown first. `In the command list present above, it contains a commit along with the secured hash SHA1 checksum, name of the author, his e-mail id, date authored and the commit message.

    79. What is the difference between author and committer in Git?


    Author is the person who authored the project i.e., who originally wrote the project. Committer is the person who committed changes to the project recently. Therefore, if an user sends a patch to a project and if any of the members in the group applies the patch, both the author and the committer will be credited.

    80. How will you undo things in Git?


    Generally, humans were prone to errors. Git allows some basic tools to undo changes which are made by a user. But, we can’t undo everything. So, a user has to be cautious while doing a work or he may suffer in loss of the work in Git. Commonly, we use this undo option while we commit very early and forget to add some files to it. Sometimes, the commit message might go wrong. In those cases, users can redo that commit. User can change what he actually wanted to do and then he can commit again through –amend option.

    $git commit –amend

    This command uses your staging for the commit.

    81. What do you mean by remote repository in Git?


    If the user wishes to combine or merge on any Git project, he must know about managing the remote repositories. Remote repository refers to a version of a project which is hosted over the internet or in a network elsewhere. We may find various remote repositories and every repository among them will perform read/write operations or read-only operations. Merging with some other’s work needs to manage these remote repositories. Users have to push/pull data to and fro from them while sharing our work to others. Managing remote repositories will perform many of the following tasks: user has to know the manner to add remote  repositories, delete some remote repositories which are not valid, have to manage several branches by defining every branch whether they are tracked or not and many more.

    82. How will you add remote repositories in Git?


    User can use git clone command which actually adds the origin remote for him. For an instance, if the user wishes to add a new remote repository in Git as a short name, run this command:

    • $git remote add<Short name><URL>
    • $git remote
    • Origin
    • $git remote add pb https://github.com/author1/ticgit
    • $git remote-v
    • Origin https://github.com/author1/ticgit …………………. Fetching
    • Origin https://github.com/author1/ticgit…………………… Pushing
    • Pb https://github.com/author2/ticgit…………………………Fetching
    • Pb https://github.com/author2/ticgit………………………….Pushing
    • Instead of using the URL, we can use the string pb on the command line now. For instance, let’s consider the user likes to fetch the entire information from author 2 which is not present in his repository, he can use git fetch pb command.
    • $git fetch pb
    • Remote: counting objects, 59 completed.
    • Remote: compressing objects: 100% (48/48., completed
    • Remote: Total 59 (delta 13., reused 43 (delta 8.
    • Unpacking objects: 100% (59/59. completed
    • From https://github.com/author2/ticgit.
    • *[new branch]  master  …… pb/master
    • *[new branch]  ticgit  …… …pb/ ticgit

    Information present in the repository of author 2 will be accessed locally through pb/master. Users can now combine it with any of the branches.

    83. How will you list your tags in Git?


    Git has a support to add tags to some particular points in the history of repository which we feel is important. Adding tags is one of the most common features present in Version control systems. Generally, users use this feature to spot release points. Users can list the existing tags uite easily in Git. The command ‘git tag’ will list the tags.

    $git tag



    This command will list the tags used in the alphabetical order.

    84. What are the types of tags that Git supports? Explain them.


    There are two types of tags supported by Git. They are:

    • Lightweight tag
    • Annotated tag

    Lightweight tags never change. It works like a branch. These tags are actually a pointer to a particular commit.

    Annotated tags were stored as entire objects in the Git DB. These type of tags were check summed and consisted of the name of the tagger, date, his mail id, the tagging message. Further, the tag has to be signed and verified by the GPG (GNU Privacy Guard..

    85. How will you create annotated tags?


    Users can create an annotated tag in Git quite easily. git tag –a will create an annotated tag. The command to create such a tag is:

    • $ git tag –a v1.5 –m “using version 1.5”
    • $ git tag
    • V0.1
    • V1.3
    • V1.4

    Here, -m will contain a tagging message specified by the tagger, which can be saved with the tag. If you want to see the tag data present and also the commit which is tagged using git, you can use the git show command. This command shows the information of the tagger, the date of the commit tagged and also the tagger message and the commit information.

    86. Write the workflow of branching and merging with some examples?


    Branching and Merging in practice requires some stage of operations to be performed. Let’s explain the process with a simple example

    • Make some work on a website
    • Build a branch for a new user

    Now, start doing some work in the created branch

    If suppose, some bug occurs at this stage and it is need to be fixed asap, perform the following operations:

    • Move to the user’s production branch
    • Build a branch to clear the bug

    Once you test it, combine the hotfix branch and then push it to production

    • Move to your actual work from where you switched and start working on it.

    87. What do you mean by long running branches?


    Because of its enhanced feature support to the users, Git offers three way easy merging of one branch to another several times for a long period. Many branches were always open which can be used in various stages of your development cycle which can be merged often from few of them to others. The code in the master branch will be completely stable which is the only possible code which has been released. Developers who use Git generally use this kind of technique. Developers use yet another parallel branch called ‘next’ or ‘develop’ to work or to test the stability but there is no certainty to be stable always. Once it reaches the stable state, it can further be merged to the master. Normally, they are used to pull from topic branches once they are stable which ensures they could clear all the tests without any errors.

    88. What do you mean by topic branches?


    As opposed to long running branches, topic branches are short lived branches. If an user needs to create a project of any size, he can go for topic branches. These types of branches can be built and used for one specific feature or task. This particular feature will not be available in any of the version control systems because this feature is not cost effective to build and combine branches. But, Git supports this feature. Using Git, this can be very ordinary for building, merging, working and deleting branches many times in a day.

    89. How will you track remote branches in Git?


    Tracking remote branches in Git can be done by checking a local branch. This monitoring will create a branch automatically which is called a tracking branch. A tracking branch track is so called as an upstream branch. These tracking branches will establish a direct connection with a remote branch. They are local branches. Tracking a remote branch can be done using ‘git pull’. Once you type this command, Git automatically understands which server to be fetched and which branch has to be merged.

    90. Explain the protocols that Git uses to transfer data.


    To transfer data, Git mainly uses the following four protocols:

    • Local
    • HTTP
    • SSH and
    • Git

    Local protocol is the generally used protocol by developers and is the very basic protocol.  In a local protocol, the remote repository is present in another directory with the same host. This protocol will be used if every member in a team enjoys access to a shared file system like NFS mount or sometimes every person in the team creates logs from the same computer. The second option might create catastrophic loss generally since all of your code repositories will be present in the same computer and therefore using this option is not advised.

    Git also uses HTTP protocol for communication using two different modes: Smart HTTP and Dumb HTTP. Smart HTTP protocol functions much similar to SSH or Git protocols but could run in standard HTTP ports using several authentication mechanisms of HTTP. If suppose the server haven’t responded with smart HTTP mechanism, the Git client will switch to the simpler Dumb HTTP protocol. Dumb protocol can be set up uite simply. User has to place a bare Git repository in the HTTP root document and has to set up a particular post-update hook. After this, anyone who wishes to access the web server where you put the repository and also they can clone the repository.

    SSH protocol is another common protocol for data transport for Git to self host through SSH. SSH protocol is set up more commonly in most places and it is very simple to do if we didn’t. It is also an authenticated network protocol

    Git protocol contains a special daemon which contains as a package with Git. This protocol works on a dedicated port and doesn’t contain any authentication. This protocol works similar to SSH.

    91. How can you resolve merge conflicts through the command line?


    Generally merge conflicts happen while the user alters one line of a file or if one deletes the same file and another edits the same file. To resolve such conflict, the user has to choose the change we need to make from several branches in a new commit. Before merging branches, users have to resolve this kind of merge conflict with a new commit.

    • Open the terminal window : TerminalGit Bash the terminal
    • Move to the local Git repository which contains the merge conflict


    92. Create a list of files which contains merge conflict?


    • Open the text editor of your wish (namely Atom. and move to the file which contains merge conflicts.
    • To identify the starting point of the merge conflict from your file, search that file for the conflict marker.
    • If the user likes to retain his branch’s changes alone, retain that changes else make some changes which will make changes in both of the branches. Then, delete the conflict markers and do changes in the final merge you wish to make.

           Now, add a change or stage your changes

    $ git add

    Then, commit your changes using some comment.

    $ git commit –m “Merge Conflict is resolved”

    93. What do you mean by a bare repository?


    Generally a bare repository in Git will contain details about the version control and the idle files (files not working. and also it won’t have the special Git subdirectory. But, the repository will contain the Git subdirectory contents in its main directory and the current working directory will contain it. a Git subdirectory consisting of Git connected history of user’s repository and ii. verified copies of user’s project file(working tree..

    94. Explain the steps to resolve a conflict in git?


    The following are the steps to resolve a conflict in Git:

    • Locate the files which generated the conflict.
    • Do required changes to the files and ensure the conflict won’t repeat again.

    95. How will you differentiate between Git and GitHub?


    Git is a high-quality version control system. It is distributed in nature and is employed to track changes in source code throughout software development. It has a unique branching model that helps in synchronizing work among developers and tracking changes in any files.

    The primary goals of Git are speed, data integrity, providing support to distributed, non-linear workflows. Git is installed and maintained on the local machine, instead of the cloud.

    GitHub is a cloud-based Git repository hosting service that brings teams together. It gives you a web-based GUI as well as provides access control and many collaboration features, fundamental task management tools for each project.

    Also, GitHub is an open-source i.e. code is kept on a centralized server and can be accessed by everyone.

    96. What are the advantages of Git over SVN?


    Since Git is an open source version control system it lets you run multiple versions of your project so that it shows the changes that are made to the code over time and if needed you can keep a track of the changes that you have made. This means that large number of developers can make their own changes and upload those changes so that the changes can be attributed to the particular developers

    97. Why do we need branching in GIT?


    With the help of branching you can have your own branch and you can also jump between the various branches. You can go to your previous work while at the same time keeping your recent work intact.

    98. What is the regular way for branching in GIT?


    The best way to create a branch in GIT is to have one ‘main’ branch and then create another branch for implementing the changes that you want to make. This is extremely useful when there are a large number of developers working on a single project.

    99. How to identify if a certain branch has been merged into master?


    Git branch –merged master – shows all branches that are merged into master

    • Git branch – merged – shows all branches that are merged into the head
    • Git branch – no-merged –shows all the branches that are not merged

    100. State a way to create a new branch in Git?


    If you want to create a new feature into the main branch then you can use the command ‘git merge’ or ‘git pull’.

    Are you looking training with Right Jobs?

    Contact Us
    Get Training Quote for Free