Top Answers to Git Interview Questions
|Type of version control||Distributed||Centralized|
|Access to networks||Not mandatory||Mandatory|
|Global revision number||Not available||Available|
|Content||Cryptographic SHA-1 Hash||No hashed content|
Here we list some of the most important differences between Git and SVN:
- When it comes to handling large files, Git is not preferred but SVN can handle multiple projects in the same repository
- Git does not have ‘commits’ across multiple branches but SVN lets you create the folders on any location in the repository layout
- You cannot commit changes in Git but SVN lets you create a tag as a branch and you can create multiple revisions under a root tag
Here are some of the most important advantages of Git:
- Data redundancy and data replication is possible
- It is a highly available service
- For one repository you can have only one directory of Git
- The network performance and disk utilization are excellent
- It is very easy to collaborate on any project
- You can work on any sort of project within the Git
C is the programming language that is used for creating Git which ensures that the overheads are reduced.
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.
When you are making the commits you can make changes to it, format it and review it in the intermediate area known as ‘Staging Area’ or ‘Index’.
The Git stash will take the working directory in the current state and index it to put on the stack at a later stage so that what you get is a clean working directory. This means that if you are in the middle of some task and need to get a clean working directory and simultaneously you want to keep all your current edits then you can use the Git stash.
When you are finished with working on the stashed item or want to remove the list then you can use the Git stash drop. This will ensure that the item that is last added by default or any particular item can be removed from the argument.
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
The Git clone command lets you copy the existing Git repository. If you want to get a copy of the central repository then the best way to do it is using ‘cloning’.
The ‘Git config’ is a great way to configure your options for the Git installation. Using this command you can define the repository behavior, preferences and user information.
- the state of a project at a given point of time is contained in a set of files
- Parent object commit references
- A 40-character string that uniquely identifies the commit object called a SHAI name
If you want to create a repository in Git then you need to run the command “git init”. With this command .git repository you can create a directory in the project directory.
The reference to a commit object is called as the ‘head’. Every repository has a ‘Master’ which is the default head. There can be multiple heads in a repository.
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.
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.
If you want to create a new feature into the main branch then you can use the command ‘git merge’ or ‘git pull’.
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.
If you want to resolve a conflict in Git then you need to edit the files for fixing the conflicting changes and then you can run “git add” to add the resolved files and after that you can run the ‘git commit’ for committing the repaired merge.