DEV Community

Cover image for Git Theory Questions💥
stalin s
stalin s

Posted on

Git Theory Questions💥

What is GIT?✋✋✋✋

Solution: GIT is a distributed version control system and source code management (SCM) system with an emphasis to handle small and large projects with speed and efficiency.

What is a repository in GIT?✋✋✋✋✋✋

Solution: A repository contains a directory named .git, where git keeps all of its metadata for the repository. The content of the .git directory is private to git.

What is the GIT version contorl?✋✋✋

Solution: With the help of GIT version control, you can track the history of a collection of files and includes the functionality to revert the collection of files to another version. Each version captures a snapshot of the file system at a certain point in time. A collection of files and their complete history are stored in a repository.

what is the command you can use to write a commit message?✋

Solution: The command that is used to write a commit message is “git commit –a”. The –a on the command line instructs git to commit the new content of all tracked files that have been modified. You can use “git add” before git commit –an if new files need to be committed for the first time.

what is the difference between GIT and SVN?✋✋✋✋

Solution: The difference between GIT and SVN is

Git is less preferred for handling extremely large files or frequently changing binary files while SVN can handle multiple projects stored in the same repository.
GIT does not support ‘commits’ across multiple branches or tags. Subversion allows the creation of folders at any location in the repository layout.
Gits are unchangeable, while Subversion allows committers to treat a tag as a branch and to create multiple revisions under a tag root.

what are the advantages of using GIT?✋✋

Solution:
Data redundancy and replication
High availability
Only one. git directory per repository
Superior disk utilization and network performance
Collaboration friendly
Any sort of projects can use GIT

what is the function of 'git config'?✋✋✋✋

Solution:
The ‘git config’ command is a convenient way to set configuration options for your Git installation. The behavior of a repository, user info, preferences, etc. can be defined through this command.

What language is used in GIT?✋✋✋✋

Solution: GIT is fast, and the ‘C’ language makes this possible by reducing the overhead of runtimes associated with higher languages.

what is "staging area" or "index" in GIT?✋✋✋

Solution:
Before completing the commits, it can be formatted and reviewed in an intermediate area known as ‘Staging Area’ or ‘Index’.

what is GIT stash?✋✋✋

Solution:
GIT stash takes the current state of the working directory and index and puts in on the stack for later and gives you back a clean working directory. So in case if you are in the middle of something and need to jump over to the other job, and at the same time you don’t want to lose your current edits then you can use GIT stash.

what is the function of the git clone?✋✋

Solution: The git clone command creates a copy of an existing Git repository. To get a copy of a central repository, ‘cloning’ is the most common way used by programmers.

how can you create a repository in GIT?✋✋✋

Solution:
In Git, to create a repository, create a directory for the project if it does not exist, and then run the command “git init”. By running this command .git directory will be created in the project directory, the directory does not need to be empty.

what is 'head' in git and how many heads can be created in a repository?✋✋

Solution: A ‘head’ is simply a reference to a commit object. In every repository, there is a default head referred to as “Master”. A repository can contain any number of heads.

what is the purpose of branching in GIT?✋✋✋

Solution:
The purpose of branching in GIT is that you can create your own branch and jump between those branches. It will allow you to go to your previous work keeping your recent work intact.

What is the common branching pattern in GIT?✋✋

Solution:

The common way of creating a branch in GIT is to maintain one as “Main“

branch and create another branch to implement new features. This pattern is particularly useful when there are multiple developers working on a single project.

how can you bring a new feature to the main branch?

Solution:
To bring a new feature to the main branch, you can use the command “git merge” or “git pull command”.

What is a ‘conflict’ in git?

Solution: A ‘conflict’ arises when the commit that has to be merged has some change in one place, and the current commit also has a change at the same place. Git will not be able to predict which change should take precedence.

How can conflict in git resolved?✋✋✋

Solution: To resolve the conflict in git, edit the files to fix the conflicting changes and then add the resolved files by running “git add” after that to commit the repaired merge, run “git commit”. Git remembers that you are in the middle of a merger, so it sets the parents of the commit correctly.

To delete a branch what is the command that is used?✋✋✋

Solution: Once your development branch is merged into the main branch, you don’t need

development branch. To delete a branch use, the command “git branch –d [head]”.

What is the difference between ‘git remote’ and ‘git clone?

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

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 function of ‘git stash apply?

When you want to continue working where you have left your work, the ‘git stash apply command is used to bring back the saved changes onto the working directory.

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.

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.

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.

Thank you :)

Top comments (0)