Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git shallow clone since specific commit

I'd like to clone a repository with a longish history. I'm only interested in a few short-lived not-yet-merged feature branches and master.

In order to not confuse myself with all that past history and merged branches, I'd like to do a shallow clone starting at a specific commit SHA.

However, so far I've only found documentation on how to do shallow clones that only include the last n commits (--depth) resp, the commits since a specific date (--shallow-since).

Is there a way to specify a shallow-clone starting at a given commit?

like image 366
umläute Avatar asked Sep 02 '18 19:09

umläute


People also ask

Can you git clone a specific commit?

Git Clone From Specific Commit ID There is no direct way to clone directly using the commit ID. But you can clone from a git tag. However, you can do the following workaround to perform a clone if it is really necessary. The above steps will make your current HEAD pointing to the specific commit id SHA.

How do I clone a specific tag?

git clone If you only need the specific tag, you can pass the --single-branch flag, which prevents fetching all the branches in the cloned repository. With the --single-branch flag, only the branch/tag specified by the --branch option is cloned. $ git clone -b <tagname> –single-branch <repository> .


1 Answers

There is not, which is kind of a shame since it would be easy for Git to implement.

Usually using --depth is sufficient: just start with a depth you think is enough, and if it's not, repeatedly fetch with --deepen or --depth as needed.

like image 58
torek Avatar answered Oct 13 '22 04:10

torek