How To Clone Git Branch Command Tutorial with Examples?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-clone-git-branch-command-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM

git clone command is used to clone branches and git repositories. In this tutorial, we will learn how to clone a git branch in different ways. We will learn clone single branch, clone to a specific folder, clone specific tag etc in this tutorial.

List Branches

We will start by listing branches. In order to copy branch, we need to list the branches. We will just use branch command which will list currently existing local and remote branches.

List Branches
List Branches

Clone Single Specified Branch

We can clone a single specific branch by using --single-branch with the --branch option. We will also provide the branch name.  This will save from the disk space where only specified branch and related data will be copied.

Clone Single Specified Branch
Clone Single Specified Branch

Clone To Specific Folder

We can copy a specific branch to the specified folder. We will just add the folder name to the end of the command. This folder will be created automatically. In this example, we will copy the master branch of the nmap into a folder named test.

Clone To Specific Folder
Clone To Specific Folder

Clone Specific Tag

We have the ability to clone specific tag. Actually, tag is the name of the branch but tag will provide a different point of view. We will use -branch option and provide the tag we want to copy. We will copy tag named master in this example.

LEARN MORE  How To Reset Git Head?

Shallow Clone or Specify Depth

Branch copy operation will all previous versions of the specified branch or tag. In some cases, this may create problems like disk space or network bandwidth. In this example, we will use --depth option and provide the number of depth which is 2 in this case.

Shallow Clone or Specify Depth
Shallow Clone or Specify Depth

 

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/how-to-clone-git-branch-command-tutorial-with-examples/
PINTEREST
PINTEREST
INSTAGRAM