As the last step, we need to merge the tags. Now we have merged all the branches we wanted into the new repository. Merge tags from source repositories into destination repository Next we merge the other branches from the source repositories. Merge other branches from source repositories into destination repositoryĪt this stage the combined repository’s master branch is complete. When all the separate repositories have been merged, we push the result to the remote. Merge master branch from source repository to destination repositoryįinally we merge the processed repository into the newly founded repository. The following code rewrites the repository’s history to make it look like the files had always been in a subdirectory named myfolder. This is needed so that we can still easily access the revision history of the files with git log command without the –follow switch that is normally required after moving files. Rewrite source repository’s history on workstationĪfter cleaning up we rewrite the repository’s history to make it look like the files had always resided in a subdirectory. The other parameters –tag-name-filter cat processes all the tags and –all all the branches. This way the processing proceeds significantly faster. The most important parameters are –index-filter and –cached which tell the command to process the commits making use of the index instead of the checked out files (as –tree-filter does). The command has been designed for rewriting large amount of commits in a scriptable way. Here we use the most robust Git history rewriting tool filter-branch. The following code shows how a single file (bigfile.zip) and a single directory (bigfolder) can be cleaned up from a repository including all the branches and all the tags. The files determined to be removed in the analysis phase are erased from the Git repository’s history. Clean up source repository on workstationĪt this stage we perform the cleanup tasks. After this the remotes of the cloned repositories are removed so that we don’t end up making changes in the original repositories by accident. We perform so called deep clone and this is a prerequisite for the cleaning operation to succeed. The actual migration process starts by cloning the source repository to the workstation including all the branches and all the tags. After the analysis is complete we have a list of files to be erased from the source repositories’ history in a later phase. The repository has to be optimized with git-gc command for all the files to be included in the scan. The script works by going through the repository’s packfiles and printing them out in order and nicely formatted. The analysis is performed with a script published by Antony Stubbs. The job starts by finding out the most space taking files in the source repositories’ Git history. Merge tags from source repositories into destination repositoryįind out space taking files in the source repositories’ Git history.Merge other branches from source repositories into destination repository.Merge master branch from source repository to destination repository.Rewrite source repository’s history on workstation.Clean up source repository on workstation.Find out space taking files in the source repositories’ Git history.The implementation plan turned out as in the picture below. The destination repository would contain the source repositories under their own subdirectories. In the process we needed to find and erase the largest unnecessary files from Git history to keep the new repository slim in size. This operation is a bit more involved than basic use of Git so I decided to write a little blog about it.įurther it was required that all the branches and tags from the separate repositories would be merged into the new combined repository. The separate repositories had been under active development for the last two years and their combined size had grown to over 600MB. A while ago in a customer project we needed to merge multiple (5) Git repositories into single one retaining full history.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |