git-subcopy 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 worksYou 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 existsPick 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 projectThis 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. UsageHere's an example screencast of me messing around with the toolminutes after the initial version was completed:
InstallationI 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 |
请发表评论