Loading, please wait...

A to Z Full Forms and Acronyms

Git Interview Questions & Answers with hands-on exercises | Part 1

Jun 24, 2021 Git, Git Interview, Git Commands, 2383 Views
This article will helps you to crack Interview on git with hands-on exercises. This is part 1 for this gitinterview questions list

The core objective of this article is to share the different ways of asking git related questions in the interviews. I have tried my best to cover basic to experienced level questions. I know covering all git topics is not possible in a single article therefore I decided to prepare a series of articles. I’m sure you shall understand git quite easily and it will be helpful for you to crack the git questions.
Please note: I’ve Microsoft Windows operation system in my computer, therefore, my practical examples will follow the Windows git command pattern.
Best of luck in advance…

What do you know about git?

Or

Can you give a brief introduction of git?

Or

Have you used git? If yes, what is that?

Explanation:

  • It is Distributed Version Control System
  • It is a Command-Line tool
  • It works in a terminal window and gets integrated with PowerShell, Command Prompt terminal
  • Git basically takes an image of what all your files look like at that moment and stores a reference to that snapshot.
  • Though git works in distributed and disconnected mode (until you explicitly push the changes to remote), mostly it works locally.

How can we install git?

Explanation:

There is many ways to get the Git in the local system or any remotely located system. Get into the system and use any way from the below:

  1. Download git from its official site
    Download the latest version of git according to the operating server you have in your computer.
    https://git-scm.com

    git is available for Windows, macOS, and Linux operating systems. The installation is quite straight forward. Just follow the Wizard instructions and do it.
  2. Install through the package manager
    git can also be installed through a chocolatey package manager.
    Follow the https://chocolatey.org/packages/git

    To install Git, run the following command from the command line or from PowerShell:

    Screen1: Steps of git installation using Chocolatey

How to check the git version using CLI?

Explanation:

Open Using command prompt or PowerShell and use the below command to check git version:

git version
or
git –version

Both would return the same result.

Do we have git GUI tools for our operating systems?

Explanation:

Indeed, there are a variety of GUI tools are available for Windows, macOS, and Linux for computer operating systems and few are for Android and iOS mobile operating systems. Though git is a Command-Line (CL) based utility there are various GUI available to use git.
I’ve worked upon the following very popular git GUIs and as per my preference of usage, I have kept these in chronological order.

GUI name

Supported OS

Link to download

Free/Paid

SourceTree

Windows, Mac

https://www.sourcetreeapp.com/

Free

GitKraken

Windows, Mac, Linux

https://www.gitkraken.com/

Free for non-commercial users else paid

GitHub Desktop

Windows, Mac

https://desktop.github.com/

Free

Tower

Windows, Mac

https://www.git-tower.com/windows

Paid

How to start working on git?

Explanation:

Before start using git, you must recall that git is a version control system and git has the additional privilege to keep version tracking locally and remotely. So, if you are configuring git, it will manage the repository locally. So, let get started…

I assume, currently, we don’t have anything linked with the remote repository and solely working LOCALLY.

Step 1: Go to your working directory. Initialize the git repository using the following command.

D:\Learning\git>git init LearningProject

This command will initialize the empty git repository in your current working directory.

Once successfully initialized, git, will create a hidden directory in your working directory called “.git” and a new folder with your defined project name will be created. In our case, it will be “LearningProject”.
Note: This is very very important to understand that the .git hidden folder is the real mechanism that manages all the git related operations on your repository.

For a beginner, it is not really necessary to understand the .git folder in detail but for an experienced person, one should at least know some basics.

The .git hidden folder consists of various sub-folders and files. We may have a super quick look.

hooks: Git hooks folder consists of the scripts that are executed before or after the events.
info: it contains the exclude file. We’ll discuss .gitignore sometime later.
objects: a much important folder that contains saved content as the hash value.
refs: contains references and tags information
config: This file contains all the configuration you would set for your project is saved permanently in this file like username, email, etc.
description: This file contains the data about the repositories which can be seen on GitWeb only
HEAD: The Head file contains the reference to the branch we are currently working on.
Step 2:
Put the content in the project folder. Git does not bother what kind of project are you keeping under it.
This could be any type of file or a complete project irrespective of any programming language.

Stopping this article here and would come back in Part 2 article with followings:

  • Config git for global usage in your system
  • Create a dot net project and apply git commands for version control

Continue Reading: Part 2

Thanks for reading. Happy learning!

A to Z Full Forms and Acronyms

Related Article