Blog

Moving a Git directory on a separate repo with the history

During your life as a busy developer, you might reach a point were your Git repo is huge and part of it would make sense to move it into a separate repository. It happened to us today in PPH, when we decided to move all our puppet modules out of our old configuration repository.

To start with, I cloned the existing repository into a separate folder so that I could mess with it as I liked (line 1) then I removed the origin to avoid accidental commit/push (line 3) and stripped out everything except the content of the directory I wanted to move in the separate repository using git-filter-branch (line 4)

At that point, the root folder of repoONE contained only the files of the exampleDir folder while the rest was wiped away. The next step was to create a new repository, add the repoONE as remote (line 4) and pull from it (line 5) then remove the remote repoONE (line 6).

RepoTWO, at that point, contained all the files I wanted along with the history.

Job Done!

Tags > , ,

No Comment

Post A Comment