#git-repository #git-clone #git #git-checkout #domain-name #location

app git-grab

一个将 Git 仓库克隆到标准位置的工具,按域名和路径组织

7 个版本 (稳定)

3.0.0 2024年5月29日
2.1.0 2024年3月25日
2.0.0 2023年12月4日
1.0.1 2022年7月7日
0.1.2 2021年7月11日

#55开发工具

每月 32 次下载

MIT/Apache

27KB
600

⤵️
Git Grab

一个将 Git 仓库克隆到标准位置的简单工具,按域名和路径组织。它在 BSD、Linux、macOS、Windows 以及更多操作系统上运行。


Git Grab 将仓库克隆到 $GRAB_HOME,按域名和路径组织。如果未设置或通过 --home 参数提供,则 GRAB_HOME 默认为 ~/src。例如

$ git grab github.com/wezm/git-grab
Cloning into '/home/wmoore/src/github.com/wezm/git-grab'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 30 (delta 9), reused 27 (delta 7), pack-reused 0
Receiving objects: 100% (30/30), 12.50 KiB | 12.50 MiB/s, done.
Resolving deltas: 100% (9/9), done.
Grabbed https://github.com/wezm/git-grab to /home/wmoore/src/github.com/wezm/git-grab

$ lsd --tree ~/src
/home/wmoore/src
└── github.com
   └── wezm
      └── git-grab
         ├── Cargo.lock
         ├── Cargo.toml
         └── src
            ├── args.rs
            ├── grab.rs
            └── main.rs

安装

预编译二进制文件

为多个平台提供了预编译的二进制文件。

示例:下载并提取二进制文件

curl https://releases.wezm.net/git-grab/3.0.0/git-grab-3.0.0-x86_64-unknown-linux-musl.tar.gz | tar zxf -

包管理器

git-grab 已打包在以下包管理器中

  • Arch Linux: git-grab
  • Brew: brew install git-grab
  • Chimera Linux: git-grab

使用方法

安装 git-grab 后,您可以通过 git grab 来使用它。 git 会自动找到名为 git-* 的二进制文件,这意味着如果您有一个类似于 alias g=git 的 shell 别名,则 g grab 也会正常工作。

USAGE:
    git grab [OPTIONS] [URL]... [--] [GIT OPTIONS]

ARGS:
    <URL>...
        One or more git URLs to clone. Any URL accepted by `git` is valid.
        In addition, URLs without a scheme such as
        github.com/wezm/grab are also accepted.

OPTIONS:
    -h, --help
            Prints help information

    -c, --clipboard
            Paste a URL to clone from the clipboard.

        --home [default: ~/src or $GRAB_HOME]
            The directory to use as "grab home", where the URLs will be
            cloned into. Overrides the GRAB_HOME environment variable if
            set.

    -n, --dry-run
            Don't clone the repository but print what would be done.

    -V, --version
            Prints version information

GIT OPTIONS:
    Arguments after `--` will be passed to the git clone invocation.
    This can be used supply arguments like `--recurse-submodules`.

ENVIRONMENT
    GRAB_HOME
        See --home

使用 GitHub CLI

  1. 在 GitHub CLI 中配置别名

    gh alias set --shell grab 'git grab "[email protected]:$1.git"'
    
  2. 现在您可以抓取 GitHub 仓库了。例如

    gh grab wezm/git-grab
    

从源码构建

最低支持的 Rust 版本 1.70.0

git-grab 使用 Rust 实现。有关安装工具链的说明,请参阅 Rust 网站:https://rust-lang.net.cn/tools/install

编译时选项(Cargo功能)

git-grab 支持以下编译时选项

  • clipboard:启用对复制到剪贴板的URL的克隆支持
    • 此功能默认开启
    • 在UNIX和UNIX-like系统(如BSD和Linux)上,以下工具之一必须安装

从Git Checkout或发布Tarball

使用以下命令构建二进制文件:cargo build --release --locked。二进制文件将位于 target/release/git-grab

从crates.io

cargo安装git-grab

致谢

此工具灵感来源于 @jmhodges的grab。一些比较

功能 原始版本 此版本
支持的VCS Git、Mercurial、Subversion和Bazaar Git
依赖项 git
进度信息 是,由 git 提供

git-grabbendn的clipp 中集成了剪贴板代码,采用MIT许可证。

许可证

此项目可选择以下任一许可证进行双重许可

由您选择。

依赖项

~1–8.5MB
~86K SLoC