0

I want to clone this repository and used the command:

git clone https://github.com/wildfly/quickstart/tree/master/helloworld-html5

It doesn't work. I guess the URL isn't the format that's right. How can git clone this repo? Thanks.

ling
  • 1,555
  • 3
  • 18
  • 24

2 Answers2

0

Looks like you're looking too deep into the repo.

Try this:

git clone https://github.com/wildfly/quickstart.git

It should have all the files you need.

pthomsen
  • 34
  • 2
0

You can do what is known as a sparse checkout, but it's complicated and I find it to be mostly annoying for something very simple; there are 'plugins' as well that can help with this process, but I'll leave that as an exercise for you to research!

Git's model is to support the repo at the top most level. But, you can configure your working copy of the repo to only pay attention to the subfolders/files of interest.

Here are two methods (the first is my history from command-line and only fetches the branches, rather than pulling down the entire repo):

 2015  mkdir quick
 2016  cd quick
 2017  git init 
 2018  git remote add -f html5 https://github.com/wildfly/quickstart.git
 2019  ls
 2020  git config core.sparseCheckout true
 2021  echo "helloworld-html5" > .git/info/sparse-checkout
 2023  git pull html5 master
 2024  ls
 2025  cd helloworld-html5/
 2026  ls

This method will pull down everything (explicitly) and then you prune it off. It's pretty much the same method as above, but it attempts to download the entire repo first then it prunes stuff off!

  1. git clone https://github.com/wildfly/quickstart.git quickstart **Notice the .git extension, this your clue that this is a repo that you can pull down!
  2. This creates a directory called quickstart that you can do dive into (it took me about 1 min to download the entire repo).
  3. cd quickstart
  4. git config core.sparsecheckout true
  5. (inside the quickstart dir) do echo "helloworld-html5" > .git/config/sparse-checkout
  6. Then read from the tree again by doing: git read-tree -m -u HEAD (feel free to read man git read-tree for what -m and -u do.
  7. Check your directory and you now only have the helloworld-html5 folder!

If this is unsatisfactory for you, then you'll want to probably look at plugins to help you pull down the subfolder you are interested in (else read the API for CLI on git).

Update -- When I went look myself for said plugins, I actually found that you can git init and git remote add the repo without pulling the entire thing down. THEN you can do steps 4-7 and do a git pull of only the sub-folder you want! Checkout this: sparse-checkout

Justin Carroll
  • 1,362
  • 1
  • 13
  • 37