从 Github 下载目标仓库指定文件夹

从 Github 下载目标仓库指定文件夹。

HR/github-clone: ⬇️ git clone repo subdirectories

1
2
3
pip install git+git://github.com/HR/github-clone#egg=ghclone
ghclone https://github.com/HR/Crypter/tree/master/app
ghclone https://github.com/HR/Picturesque/tree/master/app/src -t li50d67757gm20556d53f08126215725a698560b

下载私有库文件的时候需要 -t 参数,需要提供账户的 OAuth token:
Creating a personal access token - GitHub Docs


git-svn 踩坑日记

太晚了,踩了半天坑,没踩出来,不过记录一下吧,没准以后还会用到 git-svn,再继续解决。
目标是通过 git svn 下载资源的目录,想法是从 stackoverflow 来的,我对 svn 一点都不了解:

1
git svn clone https://github.com/user/repo/folder/folder
1
xcode-select --install

执行前面的命令检查 CommandLineTools 是否安装,如有弹窗选择:是。一般重装系统或者系统大版本升级都要重新安装一次。

1
2
3
4
5
6
7
8
$ brew reinstall git
$ brew install apr-util
$ brew install perl
$ PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
$ echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"' >> ~/.zshrc
$ echo 'export PATH="/usr/local/opt/apr/bin:$PATH"' >> ~/.zshrc
$ echo 'export PATH="/usr/local/opt/apr-util/bin:$PATH"' >> ~/.zshrc
$ cpan SVN::Core # 这命令耗时很久

报错信息:

1
Can't locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/Cellar/git/2.27.0/share/perl5

修改文件/usr/local/opt/git/libexec/git-core/git-svn的第一行, #!/usr/bin/perl#!/usr/local/bin/perl

最终报错:

1
2
3
Bad URL passed to RA layer: Unrecognized URL scheme for 'https://github.com/PacktPub
lishing/Hands-On-Full-Stack-Development-with-Go' at /usr/local/Cellar/git/2.27.0/sha
re/perl5/Git/SVN.pm line 148.

git 关联的 svn 是它自带的 svn:

1
2
3
4
$ git svn --version
# // git-svn version 2.27.0 (svn 1.8.11)
$ svn --version
# //svn, version 1.14.0 (r1876290)

和上一个报错有共同之处。

参考文献