I have a question about git, I tried to clone a tree but without success.
git clone https://github.com/cer/event-sourcing-examples/tree/d2077e21aa677a00095f90250470ff011c132ab8/java-spring
I cloned the project
git clone https://github.com/cer/event-sourcing-examples
and I tried to switch to that tree but no effect
Would you have any suggestions ?
Best regards
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:
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.
Check if below things helps.Am using a GIT bash here.
Clone the repository.
git clone https://github.com/cer/event-sourcing-examples.git
Enter that directory
cd event-sourcing-examples/
Switch the branch(i am assuming by tree you mean branch)
git checkout wip-vagrant
wip-vagrant is a branch name
To get the update you have to issue a pull command.
git pull
If you directly want to clone the branch then follow the instructions in above comment(Micheal).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With