search

Home  >  Q&A  >  body text

git - How to clone a file in a repository

There is a project, newstart.
The files in it are as follows
test1
test2
LICENSE
README.md

git clone https://github.com/someone/ne... /tmp/newstart
will pull all four files.
test1
test2
LICENSE
README.md

Now I want to get only the test1 folder and all the things in it. Is there any way to do it?

漂亮男人漂亮男人2791 days ago671

reply all(1)I'll reply

  • PHPz

    PHPz2017-05-02 09:47:54

    Requires git1.7 or above

    $ mkdir test
    $ cd test
    $ git init
    $ git remote add -f origin https://github.com/Rozbo/puck.git
    $ git config core.sparsecheckout true #开启Sparse Checkout模式
    $ echo "app" >> .git/info/sparse-checkout #设置仅拉取app这个文件夹
    $ git pull origin master

    reply
    0
  • Cancelreply