0% found this document useful (0 votes)
14 views5 pages

GIT DVC Questions Material

Uploaded by

areeba2309d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views5 pages

GIT DVC Questions Material

Uploaded by

areeba2309d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Efficient Version Control With Git

How can a repository be created in Git?

How can Git be added to an existing


project folder?

What should a user do to detect if a branch has


already been merged into the master or not?
How can a new branch be created in
Git?

How does Git perform version control?

How can the most recent commit be


modified in Git?

How can a remote branch be deleted while


working with Git?

When should the ‘git stash’ command


be used?

What is the difference between branching


and merging in Git?

How can a newly created branch be used


in Git?

How can an existing branch be renamed?

How is a receiving branch different from


a merging branch?

V 1.0 © Aptech Limited


Effective Version Control With Git

How can a repository be created in Git?

In order to create a repository in Git, the user must create a directory for the project, in
case the directory does not exist already. After creating a directory, the user needs to run
the command ‘git init’. The execution of this command will result in the creation of .git
directory in the project directory.

How can Git be added to an existing project folder?


Even if a project folder has already been created and some files already exist, Git can be
added to it. This is typically useful when the user decides to use Git version control after
beginning work on their project. To accomplish this, follow these steps –
First, navigate to the project folder in the command prompt.
Then, initialize a Git repository in the folder using the following command: git init.

What should a user do to detect if a branch has already been


merged into the master or not?
There are two commands to check the same namely –
git branch – merged: This command lists the branches that have been merged into the
current branch.
git branch – no-merged: This command lists the branches that have not been merged.

How can a new branch be created in Git?

To create a new branch, the users can execute the following command at the command
prompt – git branch my_new_branch.

How does Git perform version control?

Git’s version control system runs on the basis of a series of snapshots, which capture the
state and contents of the project at a particular time.

V 1.0 © Aptech Limited


Effective Version Control With Git

How can the most recent commit be modified in Git?

The most recent commit can be conveniently modified using the git commit --amend
command. It allows users to combine staged changes with the previous commit instead of
creating an entirely new commit. It can also be used to simply edit the previous commit
message without changing its snapshot. However, amending does not just alter the most
recent commit, it replaces it entirely, meaning the amended commit will be a new entity
with its own ref. To Git, it will look like a brand new commit.

How can a remote branch be deleted while working with Git?

A remote branch can be deleted from the same repository. While using git branch –d
deletes a local copy, the remote branch may still exist. To delete this, the user has two
options available –
• The user may use the git push origin: –delete <name> command
• The user may use the git push origin: < name> command

When should the ‘git stash’ command be used?

The ‘git stash’ command is used to make sure that the user’s uncommitted changes are
saved for a later use, so that they can be reverted from a working copy as and when
required. The most popular use of this command can be found in the situations where the
user has forgot something in their last commit while already having started working on the
next one in the same branch.

What is the difference between branching and merging in Git?

Merging in Git is the opposite of branching. Branching refers to the process of creating a
new branch and starting a new line of development. On the other hand, merging refers to
the process of unifying two separate branches.

V 1.0 © Aptech Limited


Effective Version Control With Git

How can a newly created branch be used in Git?

The command ‘git branch’ is used to create a new branch. However, it does not shift the
development control to that branch automatically. In case, the user wants to use the newly
created, the following branch must be executed at the command prompt –
Git checkout_my_new_branch.

How can an existing Git branch be renamed?

To rename a branch, users need to only specify the new name of the branch. Users can
navigate to the branch where name has to be changed and then, execute the following
command at the command prompt: git branch –m<new_branch_name>.

How is a receiving branch different from a merging branch?

The branch to which the merge is happening is called the receiving branch. The branch
which is being merged is called the merging branch. After a successful merge, the merging
branch will be deleted and the receiving branch will have the entire integrated code for the
project.

V 1.0 © Aptech Limited

You might also like