As my friends and colleagues know, I think the history of a project is very important for development. Being able to bisect, blame or read the log have proven very useful for finding bugs and understanding why a piece of code was written the way it was. Therefore, it makes sense to do whatever is possible to make sure history is preserved when moving files across repositories. Luckily for us, git has made it extremely easy. Merging Repositories Merging a repository (bar) into another repository (foo) is easy.
$ cd /path/to/foo
$ # To use a local copy, replay the url with: file:///path/to/bar/.git
$ git remote add bar https://git.domain.com/bar.git
$ git fetch bar
$ git merge bar/master
This is it. It is very simple and retains all of the history from bar while maintaining the same commit hashes! This means that for example daed567e will point to the same commit in both foo and bar. Unfortunately it is not always that simple. Sometimes you may face conflicts, if for example you had a README file in both repositories, […]