3 Star 1 Fork 0

Gitee 极速下载 / git-subcopy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://gitlab.com/jD91mZM2/git-subcopy
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

git-subcopy Crates.io

A way to include single files or directories from large git repositories. Think of it as a crappy clone of git subtree, but with the ability to hand-pick out what you want.

How it works

You can add a subcopy to your repository in a similar way to how you can add a subtree:

git subcopy add <source url> <rev> <source file> <dest file>

Any source file in a repository can be included and mapped to any destination file. Same with directories.

This will literally clone a bare version the repository temporarily into a cached folder, and then extract out the path you selected. After this is done, it saves your configuration into a .gitcopies file similar to .gitmodules. The main reason for this is to keep track of the source revision to rebase your changes onto later. You can skip step this by replacing add with fetch.

After you've made modifications to the copied file you may want to check out the diff or run any other arbitrary git command on top of it.

git subcopy shell <source file>

will re-clone the relevant configuration from your .gitcopies file and add your changes as unstaged. This lets you run git diff, and any changes you make will be propagated back to the original repository. The checked out revision won't update, however. So to rebase, use the following command.

git subcopy rebase <source file> <new revision>

will similarly drop you in a shell with your changes applied, but this time it's commited and a rebase is started. Continue the rebase using git rebase --continue, fix any conflicts you encounter, retry until success. The standard git stuff. After you're done and exit the shell, all your changes are copied back and your new base revision is saved to the .gitcopies file.

Why this exists

Pick your poison:

  • I hate monorepos! => I'm not a huge fan of them personally, and this is a good reason why. Sometimes you just want to modify one component of something, and not have a submodule linking the entire repository for everyone building your code to download. This will let you copy separate components from a monorepo, or if you truly want to follow the unix philosophy, make a separate repository from the components you need and them submodule those in.

  • I love monorepos! => Good for you! This tool will let you selectively include code into your repository while still not making it too bloaty. You won't have to make more than one repository even though you want to fork some external project, and your users won't have to download any submodules.

  • I don't have an opinion on monorepos => Still, this tool is pretty cool and you should try it just because :)

State of the project

This is definitely not stable, both the library interface and the CLI interface are both a little hairy. In general, consider this either an alpha tool or just a proof of concept. The good news is, since all the code is being copied over and checked into git, you'll never have to worry about any loss. You should be able to replace this tool with another later if it's superseded, as all the data like your base revision is right there in plain text.

Usage

Here's an example screencast of me messing around with the tool minutes after the initial version was completed:

asciicast

Installation

I recommend installing this project (or any project!) using the Nix package manager. It will automatically fetch all native dependencies for you so you only need to run the following.

nix-env -if https://gitlab.com/jD91mZM2/git-subcopy/-/archive/master.tar.gz

Alternatively, you can manually make sure you have rust, a C compiler, and openssl installed and then use the cargo package manager to fetch this project.

cargo install git-subcopy
MIT License Copyright (c) 2019 jD91mZM2 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A way to include single files or directories from large git repositories. Think of it as a crappy clone of git subtree, but with the ability to hand-pick out what you want. 展开 收起
Rust
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Rust
1
https://gitee.com/mirrors/git-subcopy.git
git@gitee.com:mirrors/git-subcopy.git
mirrors
git-subcopy
git-subcopy
master

搜索帮助