I Cannot Clone Git Tree

I cannot clone git tree

Git cannot clone a tree directly. You need to clone the entire repository, and then check out a commit that uses the tree you want. For the sake of reducing confusions, though, do note that there is a difference between the terms "tree" and "commit", though:

  • A tree is a Git object representing a directory, and contains links to blobs (files) and other trees. A tree is not necessarily the root directory of the repository.
  • A commit object contains a link to the root tree of the repository, and some extra information such as commit message, dates and other headers.

You can only check out commits. Few Git commands deal directly with tree objects (git cat-file and git ls-tree being among the exceptions). However, the object ID in your GitHub URL is indeed the ID of a commit, so that's not a problem.

What you can do, then, is check out the commit you want into a new branch after you've cloned the repository:

git checkout -b test-branch d2077e21

If the problem you're trying to solve is just fetching a single commit (or tree) from a remote repository, then you're out of luck, because Git's remote protocol does not support that operation. If anything, if you can insert a branch into the remote repository at the commit you want, you can clone that branch directly, without any history:

git clone -b test-branch --depth 1 https://github.com/cer/event-sourcing-examples

If you can't do that, however, then you're still out of luck. The remote protocol only allows referencing named refs, not arbitrary commits.

Why cant I clone repository from GitHub

I managed to bypass the issue by using Github Desktop

Git Clone - Repository not found

If you are using two factor authorization (2FA) for your Github account then just use SSH option for cloning your repository:

Sample Image

GitHub: Clone succeeded, but checkout failed

When you clone, git gets all the objects from the remote end (compressed and stashed into the .git directory). Once it has all the pieces, it proceeds to unpack all files needed to (re)create the working directory. It is this step that fails, due to not having enough space. This might be due to a disk that is full, or a disk quota exceeded (on shared machines, quotas are often enforced to avoid having users grab more than their fair share of space).

Delete your cruft. Make sure you aren't trying to squeeze the Linux kernel or some such monster repository into your few megabytes of account space.



Related Topics



Leave a reply



Submit