0

Summary: is it possible to easily mirror a remote branch while also applying a transformation to it?

Detail: The official Arch package repo holds configuration in a folder per package:

https://github.com/archlinux/svntogit-community/tree/master/a2jmidid/trunk

It is also set up to have a branch per package which seems to point to the same place:

https://github.com/archlinux/svntogit-community/tree/packages/a2jmidid/trunk

As the repo is quite large and I'm only interested in specific packages, I'm looking for a way to track specific parts of the repo, in order to fork further. I'm also just interested in the trunk folder.

Ideally I want to end up with a repo for the above that can be accessed with:

Git://localserver/packages/a2jmidid.git

Where cloning the above ends up with the contents of the trunk folder (and related history) of the specific package.

I have used --mirror for similar before, but only for full repos and their many branches. I suspect it's worth leveraging the package branch (vs the folder in master), but I can't see how to mirror just a single branch. That also wouldn't reduce the repo to just the trunk folder.

I've tried just cloning and copying the files I'm interested in, but that doesn't persist the history.

I think the approach should be to clone, branch and delete/move the files around, and then in future pull/merge and commit, but I'm having trouble nailing the exact workflow. The intention is to schedule this update.

Spammy
  • 151
  • 8
  • 1
    You can only clone the whole repository, not a single directory in it. Concerning the branch, you have the `-b` option: `git clone -b packages/a2jmidid https://github.com/archlinux/svntogit-community.git` – Frodon Nov 27 '20 at 11:22

1 Answers1

1

After the first step of just checking out the single branch (as per @Frodon), you can actually split out a subfolder into its own branch:

git subtree split -P trunk/ -b trunks/a2jmidid

This can then be pushed as you want.

Credit here

Spammy
  • 151
  • 8