• +91 9723535972
  • info@interviewmaterial.com

GIT Interview Questions and Answers

Related Subjects

GIT Interview Questions and Answers

Question - 41 : - What is git is-tree?

Answer - 41 : -

‘git is-tree’ represents a tree object including the mode and the name of each item and the SHA-1 value of the blob or the tree.

Question - 42 : - Name a few Git commands and explain their usage.

Answer - 42 : -

          Below aresome basic Git commands:

Command

Function

git rm [file]

deletes the file from your working directory and stages the deletion.

git log 

list the version history for the current branch.

git show [commit]  

shows the metadata and content changes of the specified commit.

git tag [commitID] 

used to give tags to the specified commit.

git checkout [branch name]

git checkout -b [branch name]

used to switch from one branch to another.

creates a new branch and also switches to it.

Question - 43 : -
In Git how do you revert a commit that has already been pushed and made public?

Answer - 43 : -

There can be two approaches to tackle 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 then push it to the remote repository. This is the most obvious way to fix an error. Once you have made necessary changes to the file, then commit it to the remote repository using the command: git commit -m “commit message”

Also, you can create a new commit that undoes all changes that were made in the bad commit. To do this use the command

Question - 44 : - What is SubGit?

Answer - 44 : -

SubGit is a tool for SVN to Git migration. It can create a writable Git mirror of a local or remote Subversion repository and use both Subversion and Git as long as you like.

Now you can also include some advantages like you can do a fast one-time import from Subversion to Git or use SubGit within Atlassian Bitbucket Server. We can use SubGit to create a bi-directional Git-SVN mirror of an existing Subversion repository. You can push to Git or commit to Subversion as per your convenience. Synchronization will be done by SubGit. 

Question - 45 : - What is ‘staging area’ or ‘index’ in Git?

Answer - 45 : -

That before completing the commits, it can be formatted and reviewed in an intermediate area known as ‘Staging Area’ or ‘Index’. From the diagram it is evident that every change is first verified in the staging area I have termed it as “stage file” and then that change is committed to the repository.
                              

Question - 46 : - What work is restored when the deleted branch is recovered?

Answer - 46 : -

The files which were stashed and saved in the stash index list will be recovered back. Any untracked files will be lost. Also, it is a good idea to always stage and commit your work or stash them.
If you want to fetch the log references of a particular branch or tag then run the command – “git reflog ”.

Question - 47 : -
What is git stash?

Answer - 47 : -

Often, when you’ve been working on part of your project, things are in a messy state and you want to switch branches for some time to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is Git stash.

Stashing takes your working directory that is, your modified tracked files and staged changes and saves it on a stack of unfinished changes that you can reapply at any time.

Question - 48 : - What is the function of ‘git stash apply’?

Answer - 48 : -

If you want to continue working where you had left your work then ‘git stash apply‘ command is used to bring back the saved changes onto your current working directory.

Question - 49 : - What is the difference between the ‘git diff ’and ‘git status’?

Answer - 49 : -

‘git diff ’ depicts the changes between commits, commit and working tree, etc. whereas ‘git status’ shows you the difference between the working directory and the index, it is helpful in understanding a git more comprehensively. ‘git diff’ is similar to ‘git status’, the only difference is that it shows the differences between various commits and also between the working directory and index. 

Question - 50 : - What is the difference between ‘git remote’ and ‘git clone’?

Answer - 50 : -

‘git remote add’ creates an entry in your git config that specifies a name for a particular URL whereas ‘git clone’ creates a new git repository by copying an existing one located at the URL


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners