Mastering Version Control: Most Useful Git Q&A Commands

Git, a distributed version control system, has revolutionized the way developers collaborate and manage their codebases. Whether you’re a seasoned developer or just starting on your coding journey, understanding and mastering Git commands is crucial for efficient version control and seamless collaboration. In this article, we’ll explore the most useful GIT Q&A commands that will empower you to navigate the world of version control like a pro.

What is GIT Repository ?

A Repository is a file structure where git stores all the project based files. Git can either stores the files on the local or the remote repository.

What does Git Clone do ?

git_clone <URL>

What does the command git config do ?

The git config Command is a convenient way to set configuration options for defining the behavior of the repository, User information and preferences, git installation-based configurations, and many such things.
Ex : To setup your name and email address before using git commands, we can run the below commands.

git config --global "<<your_name>>"
git config --global "<<your_email>>"

What is conflict & how you will solve this ?

Git Usually handles features merges automatically but sometimes while working in a team environment, there might be cases of conflicts such as :
1. When two separate branches have changes to the same line in a file.
2. A file is deleted in one branch but has been modified in the other.

These conflicts have to be solved manually after discussion with the team as git will not be able to predict what and whose changes have to be given precedence.

What is the functionality of git is-tree ?

This command returns a tree object representation of the current repository along with the mode and the name of each item and SHA-1 value of the blob.

What does git status command do ?

git status Command is used for showing the difference between the working directory and the index which is helpful for understanding git in-depth and also keep track of the tracked and non tracked changes.

Define “Index” ?

Before making commits to the changes done, the developer is given provision to format and review the files and make innovations to them. All these are done in the common area which is known as ‘Index’ or ‘Staging Area’.

In the above image, the “staged” status indicates the staging area and provides an
opportunity for the people to evaluate changes before committing them.

What does git add command do ?

  • This Command adds files and changes to the index of the existing directory.
  • You Can add all changes at once using git add. Command.
  • You can add files one by one specifically using git add <filename> command.
  • You can add contents of a particular folder by using git add / <folder_name> / Command.

How you will create a git Repository ?

  • Have git installed in your system.
  • In order to create a git repository, create a folder for the project and then run git init .
  • This will create a .git file in the project folder which indicates that the Repository has been created.

What is git Stash ?

Git Stash can be used in cases where we need to switch in between branches and at the same time not wanting to lose edits in the current branch. Running the git stash command basically pushes the current working directory for other tasks.

What is the command used to delete a branch ?

  • To delete a branch we can simply use the command git branch -d [head].
  • To delete a branch locally, we can simply run the command : git branch -d <local_branch_name>
  • To delete a branch remotely, run the command: git push origin –delete <remote_branch_name>
  • Deleting a branching scenario occurs for multiple reasons. One Such Reason is to get rid of the feature branches once it has been merged into the development branch.

What are difference between Command git remote and git clone ?

git remote Command creates an entity in 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.

What is git Stash apply Command do ?

  • git stash apply command is used for bringing the work back to the working directory from the stack where the changes were stashed using git stash command.
  • This helps the developers to resume their work where they had last left their work before switching to other branches.

How git pull & git merge is connected to each other ?

git pull = git fetch + git merge

What is difference between Pull request & branch ?

Pull Request

This process is done when there is a need to put a developer’s change into another person’s code branch.


A branch is nothing but a separate version of the code.

Why do we not call git “pull request” as “push request” ?

Push request is termed so because it is done when the target repository requests us to push our changes to it.

Pull request is named as such due to the fact that the repo requests the target repository to grab(or pull) the changes from it.

What is commit object ?

A commit object consists of the following components :

a : A set of files that represents the state of a project at a given point in time.
b : Reference to parent commit objects.
c : A 40 character String termed as SHA-1 name uniquely identifies the commit object.

What command helps us know the list of branches merged to master ?

git branch –merged helps to get the list of the branches that have been merged into the current branch.
Note : git branch –no-merged lists the branches that have not been merged to the current branch.

What are the functionalities of git reset –mixed and git merge –abort ?

git reset –mixed command is used for undoing changes of the working directory and the git index.
git merge –abort command is used for stopping the merge process and returning back to the state before the merging occurred.


Congratulations! You’ve taken a significant step towards mastering Git. By understanding and utilizing these essential Git Q&A commands, you’ve equipped yourself with the tools to navigate version control confidently and collaborate seamlessly with fellow developers.