zoukankan      html  css  js  c++  java
  • GitHub用户仓库批量下载

    最近看到 Dotnet9 的博客及公众号中推送了一些 WPF 相关的文章,文中示例的显示效果挺不错,然后循着文末的指引订阅了 Abel 大神的 YouTube 频道 Design com WPF,连着看了几个视频。

    不过大神共发布更新了 47 个视频,一个个看完需要花费很多时间,而且看完后过段时间或许也就忘了。好在大神同时在 GitHub上上传了相关示例代码,我们可以将相关代码全部下载到本地进行编译,这样就可以随时看示例运行效果,也可以细细研究具体实现方式。

    可以看到,每一个示例代码都独立成库,如果分别下载仍要消耗很多时间。

    那有没有办法批量下载来提高效率呢?嗯,当然有。

    下面就将找到的方式记录下来,以备后续再次使用。

    工具软件

    在开始后面的操作前,需要确保电脑上安装了 git 软件。如果没有,可以去 官网 下载。

    安装了 git 软件之后,就可以执行 git clone 命令,也可以使用 curl、grep 这两个工具。

    查询解决方法

    如果我们只下载一个示例,可以打开命令行,然后输入下面的命令即可。

    1git clone https://github.com/Abel13/NavigationDrawer.git

    由此可见,批量下载的主要问题在于如何方便的获得 Abel13 的所有库的 clone 地址

    该问题的参考答案最终在 stackoverflow 找到。利用 GitHub 提供给开发者的公开 api 方法,使用 curl 命令执行相关的查询,然后使用 grep 匹配到想要的 clone 地址。

    编辑批量下载批处理文件

    经过尝试,执行下面的命令,就能获得我们想要的 clone 地址。如果打开的是 git bash 命令行,则可以直接执行以下命令;文中使用的是 cmder,在执行以下命令前需要先执行 bash 命令。

    1curl "https://api.github.com/users/Abel13/repos?per_page=100" | grep -w clone_url | grep -o '[ ^"]+://.+.git'

    为了方便后续操作,执行下面的命令将查询到的地址保存到 clone.bat 批处理文件中。

    1curl "https://api.github.com/users/Abel13/repos?per_page=100" | grep -w clone_url | grep -o '[ ^"]+://.+.git' > clone.bat

    然后将 clone.bat 文件拖动到文本编辑器中,在每一行前输入 git clone --depth=1后保存。

     1git clone --depth=1 https://github.com/Abel13/abel13.github.io.git
    2git clone --depth=1 https://github.com/Abel13/AcrylicWindow.git
    3git clone --depth=1 https://github.com/Abel13/AnimatedColorfulMenu.git
    4git clone --depth=1 https://github.com/Abel13/AnimatedMenu1.git
    5git clone --depth=1 https://github.com/Abel13/BarChart.git
    6git clone --depth=1 https://github.com/Abel13/bootstrap-material-design.git
    7git clone --depth=1 https://github.com/Abel13/Calculator.git
    8git clone --depth=1 https://github.com/Abel13/Chat.git
    9git clone --depth=1 https://github.com/Abel13/Clock.git
    10git clone --depth=1 https://github.com/Abel13/ContentLoader.git
    11git clone --depth=1 https://github.com/Abel13/CustomControlsHandyOrg.git
    12git clone --depth=1 https://github.com/Abel13/CustomMenu.git
    13git clone --depth=1 https://github.com/Abel13/CustomScrollbar.git
    14git clone --depth=1 https://github.com/Abel13/Dashboard1.git
    15git clone --depth=1 https://github.com/Abel13/DataChangeValidation.git
    16git clone --depth=1 https://github.com/Abel13/dctb-utfpr.git
    17git clone --depth=1 https://github.com/Abel13/DialogHost.git
    18git clone --depth=1 https://github.com/Abel13/dotnetcore_login.git
    19git clone --depth=1 https://github.com/Abel13/DropdownMenu.git
    20git clone --depth=1 https://github.com/Abel13/gauge.git
    21git clone --depth=1 https://github.com/Abel13/gitignore.git
    22git clone --depth=1 https://github.com/Abel13/go_barber.git
    23git clone --depth=1 https://github.com/Abel13/HamburgerMenu.git
    24git clone --depth=1 https://github.com/Abel13/HorizontalList.git
    25git clone --depth=1 https://github.com/Abel13/Instagram.git
    26git clone --depth=1 https://github.com/Abel13/Invoice.git
    27git clone --depth=1 https://github.com/Abel13/Login1.git
    28git clone --depth=1 https://github.com/Abel13/Login2.git
    29git clone --depth=1 https://github.com/Abel13/LoLGoal.git
    30git clone --depth=1 https://github.com/Abel13/Map.git
    31git clone --depth=1 https://github.com/Abel13/MaterialDesignCustomColor.git
    32git clone --depth=1 https://github.com/Abel13/MaterialDesignExtensions.git
    33git clone --depth=1 https://github.com/Abel13/MenuMVVM.git
    34git clone --depth=1 https://github.com/Abel13/NavigationDrawer.git
    35git clone --depth=1 https://github.com/Abel13/oneTwoThreeTesting.git
    36git clone --depth=1 https://github.com/Abel13/PaymentScreen.git
    37git clone --depth=1 https://github.com/Abel13/Pizzaria1.git
    38git clone --depth=1 https://github.com/Abel13/Player1.git
    39git clone --depth=1 https://github.com/Abel13/PointOfSale.git
    40git clone --depth=1 https://github.com/Abel13/projg.git
    41git clone --depth=1 https://github.com/Abel13/react-native-fcm.git
    42git clone --depth=1 https://github.com/Abel13/Register.git
    43git clone --depth=1 https://github.com/Abel13/RepEasy.git
    44git clone --depth=1 https://github.com/Abel13/responsivelayout.git
    45git clone --depth=1 https://github.com/Abel13/SheepFinance.git
    46git clone --depth=1 https://github.com/Abel13/ShoppingCart.git
    47git clone --depth=1 https://github.com/Abel13/SoftwareEngineeringEPFComposer.git
    48git clone --depth=1 https://github.com/Abel13/TabMenu.git
    49git clone --depth=1 https://github.com/Abel13/TabMenu2.git
    50git clone --depth=1 https://github.com/Abel13/tetris.git
    51git clone --depth=1 https://github.com/Abel13/Transitions.git
    52git clone --depth=1 https://github.com/Abel13/tutoriais.git
    53git clone --depth=1 https://github.com/Abel13/twitter.github.io.git
    54git clone --depth=1 https://github.com/Abel13/workshopUFF.git

    执行批处理

    在命令行中输入 clone.bat,开始执行批处理文件中的命令。

    然后就是等待,等待,等待下载完成(最后四个 zip 压缩包是直接下载的,使用 git clone 始终无法下载完成)。

    参考

    1. https://stackoverflow.com/questions/8713596/how-to-retrieve-the-list-of-all-github-repositories-of-a-person
    2. https://developer.github.com/v3/repos/
    3. https://man.linuxde.net/grep

    - - - End - - -


    欢迎扫码订阅我的微信公众号,阅读其它相关文章。
    欢迎扫码订阅我的微信公众号,阅读其它相关文章。

    本文作者: Lzl678
    本文链接: https://www.cnblogs.com/Lzl678/p/12189120.html
    版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!

  • 相关阅读:
    mplayer编程模式控制命令
    设置开发板启动后自启动Qt
    Linux下制作logo并显示到开发板上 .
    启动开发板,提示:can't access tty,job control turned off
    BellmanFord贝尔曼福特算法
    阿拉伯数字转中文数字
    webService
    http请求全过程
    (转)MongoDB设置访问权限、设置用户
    YTC, YTM, YTW
  • 原文地址:https://www.cnblogs.com/Lzl678/p/12189120.html
Copyright © 2011-2022 走看看