Skip to main content

Posts

git interview questions part-2

GIT  1.Why do we need git add command in GIT? GIT gives us a very good feature of staging our changes before commit. To stage the changes we use git add command. This adds our changes from working directory to the index. When we are working on multiple tasks and we want to just commit the finished tasks, we first add finished changes to staging area and then commit it. At this time git add command is very helpful. 2. Why do we use git reset command? We use git reset command to reset current HEAD to a specific state. By default it reverses the action of git add command. So we use git reset command to undo the changes of git add command. 3. What does a commit object contain? Whenever we do a commit in GIT by using git commit command, GIT creates a new commit object. This commit objects is saved to GIT repository. The commit object contains following information: 1.     HASH : The SHA1 hash of the Git tree that refers to the state of index at commit time. 2.

git interview questions

GIT 1.What is the purpose of git stash drop? In case we do not need a specific stash, we use git stash drop command to remove it from the list of stashes. By default, this command removes to latest added stash To remove a specific stash we specify as argument in the git stash drop <stashname> command. 2. What is the HEAD in GIT? A HEAD is a reference to the currently checked out commit. It is a symbolic reference to the branch that we have checked out. At any given time, one head is selected as the ‘current head’ This head is also known as HEAD (always in uppercase). 3. What is the most popular branching strategy in GIT? There are many ways to do branching in GIT. One of the popular ways is to maintain two branches: master : This branch is used for production. In this branch HEAD is always in production ready state. develop : This branch is used for development. In this branch we store the latest code developed in project. This is work in progress code. On