• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

git-subcopy: A way to include single files or directories from large git reposit ...

原作者: [db:作者] 来自: Gitee 收藏 邀请

git-subcopy Crates.io

A way to include single files or directories from large gitrepositories. Think of it as a crappy clone of git subtree, but withthe 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 youcan 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 anydestination file. Same with directories.

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

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

git subcopy shell <source file>

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

git subcopy rebase <source file> <new revision>

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

Why this exists

Pick your poison:

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

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

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

State of the project

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

Usage

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

asciicast

Installation

I recommend installing this project (or any project!) using the Nixpackage manager. It will automatically fetch all native dependenciesfor 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 fetchthis project.

cargo install git-subcopy

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
oh-my-git: An opinionated git prompt for bash and zsh发布时间:2022-02-13
下一篇:
dulwich: 纯 Python 实现的 Git发布时间:2022-02-13
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap