Top 10 Git Interview Questions-2019

If you are someone who is preparing for devOps interview or even someone who wants a deeper insight into the devops world, this blog is just for you! Asking right questions always give you deeper insight into why the thing was brought up as what purpose it actually solves. So, taking this consideration lets dive straight onto the top 10 git interview questions and their answer.

1.Difference between merge vs rebase

We have two branches, branch A and branch B. Branch B is merged into the branch A. Then, Branch A would
contain commit history of both the branches using merge command whereas in git rebase, the commit history
of only the branch A would be retained.

2.What does upstream and downstream denotes

Git follows terminology similar to that like how river flows. So, water always flow in the downwards direction
that is data is flowed downstream. So, if a repository is cloned then the local is automatically downstream whereas
one tracking the remote is called an upstream branch.

3. How git keep track of changes

Git uses algorithm called “SHA-1” that turns any document’s contents into a unique, 40 hex character compressed blob.
which are stored in your .git/objects database.Your “index” is just one file in your .git directory containing list of each file you have committed, and the files you have staged, or are ready to commit, in your repository.When you do a “git add” command, git encrypts the files in your working directory that have changed contents into their new SHA-1 hash,adds the compressed SHA-1 hash to .git/objects store, and adds that file as a line in the index file ready for committing.

4.How fetch is different from pull

git fetch really only downloads new data from a remote repository – but it doesn’t integrate any of this new data into your working files.

git pull, in contrast, is used with a different goal in mind: to update your current HEAD branch with the latest changes from the remote server. This means that pull not only downloads new data; it also directly integrates it into your current working copy files, due to which”merge conflict” can occur.

5. Data structure git uses

Object storage (under .git/obects/) is a shallow trie .Pack files use a hash table to keep track of the blobs in the pack.Finally, commits, tags, and directory blobs comprise a directed acyclic graph (DAG)

6. Difference between git And svn

The key difference is that Git is decentralized,but With Subversion, you have a Problem: The SVN Repository may be in a location you can’t reach (in your company, and you don’t have internet at the moment), you cannot commit whereas in git your local copy is a repository!

7.What is git Workflow

Git workflow is basically a recommendation as how to use git efficiently and get maximum output for your project!

8.Upstream vs origin

Upstream is the original repository that you have forked whereas origin is the fork that is your own repo on Github.

9.Biggest drawback of version control system

You rely on the remote main server all the time!And also If the central database is corrupted, the entire history could be lost!

10.what does .git folder contains

.git contains all information required for version control. If you want to clone your repo, copy .git is enough.

4 sub-directories:

  • hooks/
  • info/ : exclude file for ignored patterns
  • objects/ : all “objects”
  • refs/ : pointers to commit objects

4 files:

  • HEAD : current branch
  • config : configuration options
  • description
  • index : staging area

Here “object” includes:

  • blobs(files)
  • trees(directories)
  • commits(reference to a tree, parrent commit, etc)

Also, sharing a major excitement with all of you:) Engineer Diaries has been listed among top 100  career blogs by feedspot.com. You can checkout the list here:https://blog.feedspot.com/career_blogs/

Our Team is thankful to Feedspot and ofcourse our readers, for appreciating, loving and following us. We are to the end of our almost 3 year journey and you guys are making us work harder and harder to get the best of content reach out to you<3. Thank you for the love and we promise to get to that number one spot soon💖

Do Follow our Facebook page https://www.facebook.com/lovebeingengineer/.

Similar Blogs:

Getting Started with Bitbucket-2019

 

What are Gitlab Pipelines-2019

 

Exploring Github Guide-2019

 

Top 5 Version Control System! And The best one Is!!!!!

 

 

Step by Step Guide to working with git and github professionally-2019

 

About admin 132 Articles
Engineer Diaries started with the need to bridge the huge gap in what we are taught vs what the industry demands. We are based in Delhi, India but our blog is for everyone, in and outside tech industry❤ Feel free to reach out to us at engineerdiaries@gmail.com for any business/personal query.

Be the first to comment

Leave a Reply