Skip to content

Latest commit

 

History

History
125 lines (92 loc) · 2.92 KB

File metadata and controls

125 lines (92 loc) · 2.92 KB

split-git

Introduction

Split up the given big repo into individual package-related repos.

Goals

  • Keep the common code in a submodule in those repos (e.g., as common/).

  • Try to keep the related git history intact (using git subtree split).

  • The split-up repos are to be in the same path level as the parent one, unless a second argument is provided (see usage()).

Original motivation is to split up the monolithic rpm-specs repo into individual package-related repos.

Prerequisites

Requires Git 1.7.11+ (i.e. the git subtree command).

Installation

Copy bin/split-git into one of the paths in $PATH:

$ git clone https://github.com/riboseinc/split-git
$ export PATH="${PWD}/split-git/bin:${PATH}"
$ split-git
Usage: split-git ...

Usage

$ split-git <big-repo-path> [target-subrepo-path]

Scenario

a@b:~/big-repo$ ls
a/ b/ c/ d/ e/

a@b:~/big-repo$ ls */prepare.sh
a/prepare.sh  c/prepare.sh  e/prepare.sh
b/prepare.sh  d/prepare.sh

a@b:~/big-repo$ git branch
* split
master

a@b:~/big-repo$ mkdir /tmp/split-repos

a@b:~/big-repo$ COMMON_LINK=clone \
>   SUB_REPO_PREFIX=myrepo- \
>   SUB_REPO_INDICATOR_FILE=prepare.sh \
>   BIG_REPO_POST_SPLIT_BRANCH=split \
>   BIG_REPO_REF_IN_SUB_REPO=common \
>   BIG_REPO_SPLIT_BRANCH_PREFIX=split- \
>   split-git ~/big-repo /tmp/split-repos
... ...

a@b:~/big-repo$ cd /tmp/split-repos; ls
myrepo-a/  myrepo-c/  myrepo-e/
myrepo-b/  myrepo-d/

a@b:/tmp/split-repos$ cd myrepo-a; ls
common/

a@b:/tmp/split-repos/myrepo-a$ cd common; git branch
* split
split-a
split-b
split-c
split-d
split-e
master

Parameters

COMMON_LINK
  • enums: clone|sym|sub

  • default: sub

  • The method { sub | sym | clone } to use when linking from sub-repo to the big-repo

SUB_REPO_PREFIX
  • default: myrepo-

  • The prefix prepended to ${package_name}, as the sub-repo name

SUB_REPO_INDICATOR_FILE
  • default: prepare.sh

  • The file within a subfolder in big-repo that indicates fit for splitting

BIG_REPO_POST_SPLIT_BRANCH
  • default: split

  • The branch in big repo crafted for post-split operations

BIG_REPO_REF_IN_SUB_REPO
  • default: common

  • The path within each sub-repo that references the big repo

BIG_REPO_SPLIT_BRANCH_PREFIX
  • default: split-

  • The branch name prefix for each sub-repo-branch created in big repo

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/riboseinc/split-git. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The software is available as open source under the terms of the MIT License.