For Your Guidance – Technology

Git clone is used to clone the remote repository to the local machine.

Clone the repository

Git clone <repo URL>

This command will create a new folder with the repo name and then download all the information related to the repository (including commit information, branches, snapshots…etc)

Clone the repository to the new folder

Git clone <repo URL> <folder name>

By default, git clone will create a folder with a repo name to download the source code. If we want to clone the source code with a different folder name other than the repo name, then we should add the required folder name at the end of the command.

Clone repo with limited number of commit information

Git clone --depth <number of commits> <repo URL>

Git clone is used to pull the entire commit history. Suppose, if the repo has large number of commits history, then the repo memory will increase. Sometimes git metadata memory will be larger than the source code.

Instead of unnecessarily downloading all the commit history, we can limit the commit history. So that, git can download fast.

Note: by default, this will download only the default branch.

Clone repo with limited number of commits for all branches

Git clone --depth 1 --no-single-branch <repo URL>

This command is used to download the limited number of commit histories for all branches.

5/5
Tags: clone / GIT / SCM
Categories: DevOps / GIT

Latest Posts