Latest GIT Interview Questions and Answers
What is ‘git status’ is used for?
As ‘Git Status’ shows you the difference between the working directory and the index, it is helpful in understanding a git more comprehensively.
What is the difference between the ‘git diff ’and ‘git status’?
‘git diff’ is similar to ‘git status’, but it shows the differences between various commits and also between the working directory and index.
What is the function of ‘git checkout’ in git?
A ‘git checkout’ command is used to update directories or specific files in your working tree with those from another branch without merging it in the whole branch.
What is the function of ‘git rm’?
To remove the file from the staging area and also off your disk ‘git rm’ is used.
What is the function of ‘git stash apply’?
When you want to continue working where you have left your work, ‘git stash apply’ command is used to bring back the saved changes onto the working directory.
What is the use of ‘git log’?
To find specific commits in your project history- by author, date, content or history ‘git log’ is used.
What is ‘git add’ is used for?
‘git add’ adds file changes in your existing directory to your index.
What is the function of ‘git reset’?
The function of ‘Git Reset’ is to reset your index as well as the working directory to the state of your last commit.
What is git Is-tree?
‘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.
How git instaweb is used?
‘Git Instaweb’ automatically directs a web browser and runs webserver with an interface into your local repository.
What does ‘hooks’ consist of in git?
This directory consists of Shell scripts which are activated after running the corresponding Git commands. For example, git will try to execute the post-commit script after you run a commit.
Explain what is commit message?
Commit message is a feature of git which appears when you commit a change. Git provides you a text editor where you can enter the modifications made in commits.
How can you fix a broken commit?
To fix any broken commit, you will use the command “git commit—amend”. By running this command, you can fix the broken commit message in the editor.
Why is it advisable to create an additional commit rather than amending an existing commit?
There are couple of reason
a) The amend operation will destroy the state that was previously saved in a commit. If it’s just the commit message being changed then that’s not an issue. But if the contents are being amended then chances of eliminating something important remains more.
b) Abusing “git commit- amend” can cause a small commit to grow and acquire unrelated changes.
What is ‘bare repository’ in GIT?
To co-ordinate with the distributed development and developers team, especially when you are working on a project from multiple computers ‘Bare Repository’ is used. A bare repository comprises of a version history of your code.