Git Interview Questions for freshers/Git Interview Questions and Answers for Freshers & Experienced

What does git annotate command do?

<> This command annotates each line within the given file with information from the commit which introduced that change. This command can also optionally annotate from a given revision.
<> Syntax: git annotate [<options>] <file> [<revision>]
<> You can get to learn more about this command from the official git documentation here

Posted Date:- 2021-10-18 05:52:46

Can you tell something about git reflog?

This command tracks every single change made in the repository references (that can be branches or tags) and also maintains the branches/tags log history that was either created locally or checked out. Reference logs such as the commit snapshot of when the branch was created or cloned, checked-out, renamed, or any commits made on the branch are maintained by Git and listed by the ‘reflog’ command.

<> This recovery of the branch is only possible when the branch was either created locally or checked-out from a remote repository in your local repository for Git to store its reference history logs.

<> This command should be executed in the repository that had the lost branch.

Posted Date:- 2021-10-18 05:46:44

How can you discover if a branch has already been merged or not?

There are two commands to determine these two different things.

<> git branch --merged - Gives the list of branches that have been merged into the current branch.

<> git branch --no-merged - Gives the list of branches that have not been merged.

Posted Date:- 2021-10-18 05:45:16

If you recover a deleted branch, what work is restored?

The files that were stashed and saved in the stash index can be recovered. The files that were untracked will be lost. That’s why it's a good idea to stage and commit your work or stash them.

Posted Date:- 2021-10-18 05:43:53

How do you find a list of files that has been changed in a particular commit?

The command to get a list of files that has been changed in a particular commit is:

git diff-tree –r {commit hash}

* -r flag allows the command to list individual files
* commit hash lists all the files that were changed or added in the commit.

Posted Date:- 2021-10-18 05:43:01

What does the git reset --mixed and git merge --abort commands do?

git reset --mixed is used to undo changes made in the working directory and staging area.

git merge --abort helps stop the merge process and return back to the state before the merging began.

Posted Date:- 2021-10-18 05:41:54

How is git instaweb used?

‘git instaweb’ is used to automatically direct a web browser and run a webserver with an interface into your local repository.

Posted Date:- 2021-10-18 05:40:30

What is ‘bare repository’ in Git?

A “bare” repository in Git contains information about the version control and no working files (no tree) and it doesn’t contain the special .git sub-directory. Instead, it contains all the contents of the .git sub-directory directly in the main directory itself, whereas the working directory consists of :

1. A .git subdirectory with all the Git related revision history of your repository.
2. A working tree, or checked out copies of your project files.

Posted Date:- 2021-10-18 05:39:41

What does git stash apply command do?

<> git stash apply command is used for bringing the works 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

Posted Date:- 2021-10-18 05:38:39

What differentiates between the commands git remote and git clone?

git remote command creates an entry 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.

Posted Date:- 2021-10-18 05:37:30

Tell me something about 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 state and index to the stack for future use and thereby providing a clean working directory for other tasks.

Posted Date:- 2021-10-18 05:36:18

What is a commit message?

The command that is used to write a commit message is “git commit -a”.
Now explain about -a flag by saying -a on the command line instructs git to commit the new content of all tracked files that have been modified. Also, mention you can use “git add <file>” before git commit -a if new files need to be committed for the first time.

Posted Date:- 2021-10-18 05:35:21

How can conflict in git resolved?

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.

Posted Date:- 2021-10-18 05:34:15

What is the difference between git rebase and git merge?

In git rebase, a feature branch is moved into a master. Git merge maintains the history by adding a new commit.

Posted Date:- 2021-10-18 05:33:42

What does git rebase do?

Rebasing is the reapplying of commits on top of another base trip. A sequence of commits is applied from distinct branches into the final commit. It is a linear process of merging and an alternative to the git merge command. Rebasing makes it seem like one has created a branch from a different commit.

Posted Date:- 2021-10-18 05:33:14

How to deal with huge binary files in Git?

Handling large binary files is a significant problem in git, and to handle this problem “Large File Storage” extension works well for Git. Simply install LFS on your local computer, and after this, your large files will not be stored in the local repository. Instead, it will be stored in a dedicated LFS cache and store.

Posted Date:- 2021-10-18 05:32:43

How can you change any older commit message?

To change older commit the command is –

$ git rebase –interactive

Posted Date:- 2021-10-18 05:32:03

What is the difference between git fetch and git pull?

Git fetch retrieves new data from a remote repository but does not integrate it into our working files. It helps in checking if any changes happened in the remote repository. It does not manipulate or destroy anything in the process.

Git pull, on the other hand, updates the HEAD with the latest changes from the remote server and directly integrates it into the working copy files. Using git pull can end in merge conflict as it tries to merge remote changes with the local ones.

Posted Date:- 2021-10-18 05:31:28

What is cherry-pick in Git?

Git cherry-pick is a command that allows the picking of arbitrary Git commits by reference and adding them to the HEAD. Cherry-picking is the process of picking a commit from one branch and applying it to another. It helps in undoing changes.

Posted Date:- 2021-10-18 05:30:49

How do you edit or fix the last commit message in Git?

If you forget to add anything in the commit message or committed a typo error, you can rectify it by using –amend flag command.

$ git commit –amend -m “Sorry I missed an important update”

Note: –amend flag will only help in editing or fixing the last commit message.

Posted Date:- 2021-10-18 05:30:19

State the difference between “git pull” and “git fetch.”

This is an important Git interview question. “git pull” and “git fetch” are used for downloading new data from a remote repository.

“git fetch – It downloads new data from the repository but does not support integrating this data to working files. It offers a fresh view of things that happened in the remote repository.

“git pull” – This command is used to update the current HEAD data branch with all the changes that occurred in the remote repository. Thus, it downloads the data and integrates it with existing working files.

Posted Date:- 2021-10-18 05:29:40

What is forking in Git?

A repository copy is called a fork. So, forking allows one to experiment with changes without worrying about the original project. This process is ideal for proposing changes to someone else’s projects.

Posted Date:- 2021-10-18 05:29:12

Why is it said that Git is designed keeping in mind performance, security, and flexibility?

Git was developed in 2015 by Linus Torvalds for Linux kernel development. But in the last decade, it gained a lot of interest, and today, due to its flexibility, nearly every development environment uses Git and runs Git command-line tools on every major operating system.

Below are the reasons why Git is highly recommended:

<> Performance: Git has very powerful raw performance characteristics be it branching, merging, or comparing the past versions; it is robust and optimized. Git gives special attention to the content, and it uses a blend of delta encoding and compression. Further, it also clearly stores directory contents and metadata object versions.

<> Security: Integrity is the topmost priority of Git. Its cryptography hashing algorithm named SHA1 safely stores all objects in the Git repository and maintains a true relationship between files and directories.

<> Flexibility: From supporting nonlinear development workflow to adaptability with various systems and protocols, Git is exceptionally elastic. Git’s amazing tracking system offers features like treating branching and tagging as first-class citizens. Its ‘change history’ also features stores operations affecting branches and tags.

Posted Date:- 2021-10-18 05:28:45

What is the meaning of “Index” or “Staging Area” in GIT?

When we are making the commits, we can make changes to it, format it and review it in the intermediate area known as ‘Staging Area’ or ‘Index’.

Posted Date:- 2021-10-18 05:27:41

What is a version control system? Mention its types.

A version control system (VCS) is a software tool used to create different project versions and store them in a repository. All modifications to the code are recorded and tracked by the VCS.

Types of version control systems:

Local version control systems have a database that maintains all the file changes on disk under revision control in a special format.
Centralized version control systems contain one repository, and each user gets their own working copy.
Distributed version control systems contain multiple repositories, each accessible to separate users with their own working copy.

Posted Date:- 2021-10-18 05:27:19

What is a merge conflict in Git?

A merge conflict is an event that takes place when Git is unable to resolve differences in code between the two commits automatically.

Git is able to automatically merge the changes only if the commits are on different lines or branches.

Posted Date:- 2021-10-18 05:26:14

Who created Git?

Git was created by Linus Torvalds in 2005 on the road to develop Linux Kernel.

Posted Date:- 2021-10-18 05:25:41

Why is it considered to be easy to work on Git?

With the help of git, developers have gained many advantages in terms of performing the development process faster and in a more efficient manner. Some of the main features of git which has made it easier to work are:

Branching Capabilities:

- Due to its sophisticated branching capabilities, developers can easily work on multiple branches for the different features of the project.
- It also has an easier merge option along with an efficient work-flow feature diagram for tracking it.

Distributed manner of development:

- Git is a distributed system and due to this nature, it became easier to trace and locate data if it's lost from the main server.
- In this system, the developer gets a repository file that is present on the server. Along with this file, a copy of this is also stored in the developer’s system which is called a local repository.
- Due to this, the scalability of the project gets drastically improved.

Pull requests feature:

- This feature helps in easier interaction amongst the developers of a team to coordinate merge-operations.
- It keeps a proper track of the changes done by developers to the code.

Effective release cycle:

- Due to the presence of a wide variety of features, git helps to increase the speed of the release cycle and helps to improve the project workflow in an efficient manner.

Posted Date:- 2021-10-18 05:21:03

What is the purpose of branching in GIT?

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.

Posted Date:- 2021-10-18 05:20:04

What does commit object contain?

a) A set of files, representing the state of a project at a given point of time

b) Reference to parent commit objects

c) An SHAI name, a 40 character string that uniquely identifies the commit object.

Posted Date:- 2021-10-18 05:19:36

What is the function of ‘git config’?

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

Posted Date:- 2021-10-18 05:19:11

How will you know in GIT if a branch has been already merged into master?

Git branch—merged lists the branches that have been merged into the current branch

Git branch—-no merged lists the branches that have not been merged

Posted Date:- 2021-10-18 05:18:17

What is GIT stash drop?

When you are done with the stashed item or want to remove it from the list, run the git ‘stash drop’ command. It will remove the last added stash item by default, and it can also remove a specific item if you include as an argument.

Posted Date:- 2021-10-18 05:17:49

What is GIT stash?

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.

Posted Date:- 2021-10-18 05:17:27

What is “Staging Area” or “Index” in GIT?

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

Posted Date:- 2021-10-18 05:16:47

Why GIT better than Subversion?

GIT is an open source version control system; it will allow you to run ‘versions’ of a project, which show the changes that were made to the code overtime also it allows you keep the backtrack if necessary and undo those changes. Multiple developers can checkout, and upload changes and each change can then be attributed to a specific developer.

Posted Date:- 2021-10-18 05:16:24

What is the function of ‘GIT PUSH’ in GIT?

‘GIT PUSH’ updates remote refs along with associated objects.

Posted Date:- 2021-10-18 05:16:04

Explain the git push command.

The Git push command is used to push the content in a local repository to a remote repository. After a local repository has been modified, a push is executed to share the modifications with remote team members.

Posted Date:- 2021-10-18 05:15:24

What is the difference between Git and Github?

Git is a version control system of distributed nature that is used to track changes in source code during software development. It aids in coordinating work among programmers, but it can be used to track changes in any set of files. The main objectives of Git are speed, data integrity, and support for distributed, non-linear workflows.

GitHub is a Git repository hosting service, plus it adds many of its own features. GitHub provides a Web-based graphical interface. It also provides access control and several collaboration features, basic task management tools for every project.

Posted Date:- 2021-10-18 05:13:35

What is a distributed VCS?

<> These are the systems that don’t rely on a central server to store a project file and all its versions.

<> In Distributed VCS, every contributor can get a local copy or “clone” of the main repository.

<> As you can see in the above diagram, every programmer can maintain a local repository which is actually the copy or clone of the central repository which is present on their hard drive. They can commit and update their local repository without any hassles.

<> With an operation called “pull”, they can update their local repositories with new data from the central server and “pull” operation affects changes to the main repository from their local repository.

Posted Date:- 2021-10-18 05:13:12

What does git clone do?

The command creates a copy (or clone) of an existing git repository. Generally, it is used to get a copy of the remote repository to the local repository.

Posted Date:- 2021-10-18 05:12:14

Name some of the popular Git hosting repositories.

* GitHub

* GitLab

* BitBucket

* Beanstalk

* FogBugz

* Surround SCM

* Buddy

Posted Date:- 2021-10-18 05:11:58

What is a commit message, and how is the commit command executed?

The commit command is executed in a Git project to record the progress in the local repository. The commit command is executed only after the files to be committed have been added to the staging area using the git add command.

Posted Date:- 2021-10-18 05:10:49

What language is used in Git?

Git is a fast and reliable version control system, and the language that makes this possible is ‘C.’

Using C language reduces the overhead of run times, which are common in high-level languages.

Posted Date:- 2021-10-18 05:10:29

What are the advantages of using Git?

* Faster release cycles
* Easy team collaboration
* Widespread acceptance
* Maintains the integrity of source code
* Pull requests

Posted Date:- 2021-10-18 05:10:07

Name a few Git commands with their function.

* Git config - Configure the username and email address
* Git add - Add one or more files to the staging area
* Git diff - View the changes made to the file
* Git init - Initialize an empty Git repository
* Git commit - Commit changes to head but not to the remote repository

Posted Date:- 2021-10-18 05:09:40

What is a version control system (VCS)?

A VCS keeps track of the contributions of the developers working as a team on the projects. They maintain the history of code changes done and with project evolution, it gives an upper hand to the developers to introduce new code, fixes bugs, and run tests with confidence that their previously working copy could be restored at any moment in case things go wrong.

Posted Date:- 2021-10-18 05:08:56

What is a Git repository?

Git repository refers to a place where all the Git files are stored. These files can either be stored on the local repository or on the remote repository.

Posted Date:- 2021-10-18 05:08:28

What do you understand by the term ‘Version Control System’?

A version control system (VCS) is a system that records all changes made to a file or set of data, so a specific version may be called later if needed.

This helps ensure that all team members are working on the latest version of the file.

Posted Date:- 2021-10-18 05:08:09

What is Git?

Git is a version control system for tracking changes in computer files and is used to help coordinate work among several people on a project while tracking progress over time. In other words, it’s a tool that facilitates source code management in software development.

Git favors both programmers and non-technical users by keeping track of their project files. It enables multiple users to work together and handles large projects efficiently.

Posted Date:- 2021-10-18 05:07:36

Search
R4R Team
R4R provides Git Freshers questions and answers (Git Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers,Git Interview Questions for freshers,Git Freshers & Experienced Interview Questions and Answers,Git Objetive choice questions and answers,Git Multiple choice questions and answers,Git objective, Git questions , Git answers,Git MCQs questions and answers R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for Git fresher interview questions ,Git Experienced interview questions,Git fresher interview questions and answers ,Git Experienced interview questions and answers,tricky Git queries for interview pdf,complex Git for practice with answers,Git for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .