Git Terminologies – Clone

Here we will see basic commands and git terminologies overview that you need to start using git. The terms are same irrespective of which Git platforms or Azure Repos , or Gitlab , and various others you refer to .

Git Repositories

Git Repositories

A Repo is a collection of files that you want to track and manage changes across the team. Typically, the source code of your project will be part of the repository. On the local machine, the git repository is created as a .git folder in the root folder of the and contains all the metadata of the files modified ,added , deleted , the files to ignore to track and other key information stored to provide the required source control features.

Git Clone

Git Clone

View the video below to understand the clone command

Clone refers to the operation where in a target repository is cloned (copied) to the current folder on the local system.

Command Overview

Let’s look at the git command in detail. Read the article <> to install the command line tool required to try this command.

git clone <url>

Above command will clone the ‘default’ branch from the repository.

Mandatory Parameters

URL – the url of the git repository to clone

Optional Parameters
-b or –branchProvide the name of the branch to clone
–depthpass the number of commits to clone instead of downloading
the complete history of commits. This reduces the size of your clone

Share your email id here, to get access to a sample repository to try out above command.

Git branch

Git Branch

A branch is a pointer to the  snapshot or a independent copy of the working code  of the repository. A new branch is generally created for a new feature a, a bug fix.As we see later in the course, it is a best practice to create a new branch for every change your team is working on.

As you can see here, i have a copy of the code called ‘Sprint 1’, now i can go ahead and create two new branches Feature 1 and Feature 2 , rmember these two branches i have created on the server .

Now, a developer working on Feature 1 can clone the branch and start making changes.

Next the developer can create two new local branches APIChanges and UICHanges, remember these are local branches.

Developer can now do all API related changes independent of UI changes and without affecting other developers work.

Next, we learn about checkout 

Git Checkout

Git Checkout

Checkout is performed whenever one wants to move the git reference from branch A to branch B.  When we checkout ,the local folder  files will be refreshed/replaced with the branch B changes.

As you see here , i have the same branching structure created previosuly. Now in this case developer has cloned Feature 1 and is currently working on related changes,

Lets say, you ask developer to start working on feature 2 , then the developer would ‘Checkout’ feature 2 branch and go ahead.

Note that, at the time of checkout, any pending change would either need to be reverted or stored for later use , we will learn about this later in the course.

Rememeber, while working on feature 1, the developer can checkout local branch APIChanges or UIChanges to work on corresponding changes.

Git Pull

Git Pull

Pull refers to an operation where in the local copy of the repository is updated with new changes done by other team members.

Going back to our Feature 1 example, As you can see the developer has cloned the Feature 1 branch and began to do required changes. During this period, Other developers have done few changes and updated the repository.Now, In order to ensure the developer has the latest code, he will PULL the code from the server repository to the local folder. 

If there are any pending changes done in the same file, the command would merge the code and update the local copy. If there are conflicts in the merge, it would prompt the developer to fix the conflicts before completing the pull.

Git Commit

Git Commit

Commit is an operation to save your changes to a local repository. Unlike other VCS, a commit in git do not automatically update the server repository.

As you can see, the developer has a local copy of Feature 1 branch , during the development of his feature he has done multiple changes and saved them  to the local repository as a commit. When the developer completes the feature he would then Push the code to the server.

Push is an operation where single or multiple COmmits are updated to the server repository.

Generally, it is a good practice to do a PULL before a PUSH to avoid any loss of code or merge issues. 

Git Push

Git Push

When the changes saved in local repository needs to be moved to server, we use a Push command

Git Pull Request

Git PR

Now, we will look at the one of the important term of git and one which we will be using quite often in this course going forward.

Pull Request  is a operation to move or merge the code from branch B to branch A.  Note that, in case of a PR , the merge would not happen automatically but wait for it to be approved.

A developer can raise a PR and add one or many reviewers to review the changes before merging the code. At this point, the reviewers can look at the changes done, provide feedback and do additional commits to ensure the code is the way it was expected. Then , the PR can be approved to be merged.

As a scrum master you have to look at enabing the  PR approach to ensure the quality and stability of the application is intact ,especially when multiple code changes are being pushed everyday.

Git Fork

Git Fork

Git Fork is generally popular with open source projects allowing any developer to fork or replicate an existing repository , for any changes related to a feature or a bug fix without needing to get permission to the main repository .you can think of form as a server-side clone of the repository . Once the changes are done developer can raise the pull request to move the code from the forked repository to the main repository.  not that on the forked repo , operation such as clone pull push it cetera are applicable on the fork repository.

Git Stash

Git Stash is commonly used by developers before a checkout. Especially when checking out a new branch when developer is in the middle of another feature or change and not yet ready to commit or push.

Stash command basically takes local changes done to the source files and back it up in a First In Last Out stack. Stash command is executed on developer machine and do not update the server repository.

Developer can any time retrieve the Stashed changes using the stash apply command

 Remember the stash apply would pick up the last set of changes pushed to the stack .

Download this pdf to get a quick reference sheet for all operations and their commands.

Read my blog on Git branching strategies to know what are various branching strategies you can apply.