• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Program for merging multiple Git repositories into one, preserving previous history, tags and branches

git-merge-repos

Program for merging multiple Git repositories into one, preserving previous history, tags and branches.

This is useful when you had multiple repositories for one project where you had more or less the same set of branches and tags.

How it works. For each branch/tag name:

  1. All the commits of the repositories that have this branch/tag are collected.
  2. The commits are merged with 1 merge commit (with N parents).
  3. The branch/tag is recreated on this merge commit. In case of an annotated tag, the tag message and tagger information is preserved (this does not work for signing information).

Usage

When merging multiple repositories, you can choose between the following two options:

  1. Preserve old commit IDs

    The old history is preserved as-is. Normally, the directory structure of the repositories needs to be moved into a subdirectory (one per repository). This will be done in the merge commit.

  2. Preserve history for paths

    The old history is first rewritten so that all content is within a subdirectory. The merge commit does not change the directory structure.

The second option has the advantage that you will still be able to see the history of a path beyond the merge. With the first option, rename detection may not be able to cope with the rename in the merge commit.

Preserve Old Commit IDs

Say you have a repository at [email protected]:foo.git and one at [email protected]:bar.git. They both have some common tags and branches.

To merge them, run the program like this:

./run.sh [email protected]:foo.git:foodir [email protected]:bar.git:bardir

This will create a merged repository as a subdirectory of the current directory.

Each tag and branch will be on a new merge commit that merges the commits for these tags/branches from foo and bar. The merge commits also change the tree structure so that the contents of foo are in foodir and the contents of bar in bardir.

Preserve History for Paths

First, install git-filter-repo. Then, with the same example as above, do the following for each repository beforehand (replace newsubdir with the name you want):

git clone --mirror [email protected]:repo.git

cd repo

git filter-repo --to-subdirectory-filter newsubdir

Then, run the program like this:

./run.sh /absolute/path/to/foo:. /absolute/path/to/bar:.

This time, we don't want the merge commit to change the directory structure, as we already did that using git filter-repo.

Dependencies

You need to have at least Java 11 installed. Note that it's also tested against newer versions such as 17. Maven, JGit and other dependencies will be automatically downloaded when running the program.

Other Solutions

License

Copyright © 2013, 2014 Robin Stocker

Licensed under the Apache License, see LICENSE file for details.

More Repositories

1

taglib-ruby

Ruby interface for the TagLib C++ library, for reading and writing meta-data (tags) of many audio formats
C++
255
star
2

autolink-java

Java library to extract links (URLs, email addresses) from plain text; fast, small and smart
Java
207
star
3

linkify

Rust library to find links such as URLs and email addresses in plain text, handling surrounding punctuation correctly
Rust
203
star
4

id3lib-ruby

Ruby interface to the id3lib C++ library for easily editing ID3 tags of MP3 audio files
C++
41
star
5

frozen-bubble-android

git svn clone of http://frozenbubbleandroid.googlecode.com/svn/
Java
34
star
6

guava-java8-presentation

Examples of using Guava, with some Java 8 additions
JavaScript
30
star
7

curlall

Simple curl-like CLI tool to automatically page through APIs
Rust
25
star
8

brainztag

Command line tool to tag and rename music albums using MusicBrainz data
Python
22
star
9

jar-manifest-formatter

Pretty-prints JAR manifest files (used by OSGi)
JavaScript
10
star
10

digitec_watcher

Script to watch the Digitec website for price or delivery status changes and send out notifications per e-mail
Ruby
7
star
11

ausballot

Tiny website for previewing the ballot papers (house and senate) for Austalian federal elections
TypeScript
5
star
12

nis-ffi

NIS (YP) library using libc's libnsl through ruby-ffi
Ruby
2
star
13

egit

Eclipse Git plugin
Java
2
star
14

advent-of-code-2022

https://adventofcode.com/2022
Java
2
star
15

ejb3unit

Fork of http://ejb3unit.sourceforge.net/ for upgrading to JPA 2.0
Java
2
star
16

7langs7weeks

Exercises from "Seven Languages in Seven Weeks"
Ruby
1
star
17

egit-mergetool-encoding-problem

Sample repository showing a bug in EGit's merge tool
1
star
18

clojure-sudoku

Simple Sudoku solver in Clojure
Clojure
1
star
19

swig-ruby-subclass-namespace-problem

Example for SWIG Ruby problem with subclass in other namespace
Ruby
1
star