GIT DVC Questions Material
GIT DVC Questions Material
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.
To create a new branch, the users can execute the following command at the command
prompt – git branch my_new_branch.
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.
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.
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
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.
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.
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.
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>.
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.