#!/bin/bash
rurl="$1" localdir="$2" && shift 2
mkdir -p "$localdir"
cd "$localdir"
git init
git remote add origin "$rurl"
git config core.sparseCheckout true
# Loops over remaining args
for i; do
echo "dir is $i"
echo "$i" >> .git/info/sparse-checkout
done
git pull origin master
eg:
./dir_clone.py "http://github.com/tj/n" "./local/location" /bin docs
ref:https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository
GitHub 「特定」文件夹或文件下载工具
http://blog.luckly-mjw.cn/tool-show/github-directory-downloader/index.html