Clone repositories without the entire history in Git – Amit Merchant – A blog on PHP, JavaScript, and more

Related Articles

There comes a time you want Cloning Git repository through GitHub or a similar client but at the same time, you do not want the entire history of this repository.

It can help speed things up git clone A process for you.

There is an instruction to do just that in Git.

So, for example, if you only want the last commit from the Git repository, you can do so by specifying --depth Option followed by the number of recent commitments you want in git clone command. In our case, it will be 1.

This is what the command will look like.

As you may know, Git will retrieve the last commit for this pool and if you git log Under this pool, you will only see this specific commit in the list.

Similarly, if you need the last 5 commitments, specify --depth 5. For 10 commitments, it will be --depth 10, Etc.

You can take it further just by retrieving the specific branch through --single-branch Such a possibility.

$ git clone -b main --single-branch [repo] --depth 1



Please enter your comment!
Please enter your name here

Popular Articles