How to start a new repo from a branch without losing a history of that branch and its child branches

I have a very old and huge GIT repo. A long time ago a branch A was created that has been acting as a main development branch since its creation. Other branches were created to implement features - always taking branch A as a root and merged back into the branch A.

What I would like to do is to start a new GIT repository. The new repository would take the creation of the branch A as its beginning (the beginning of its history). Thus I would like to abandon the previous history.

I am not a GIT beginner but since this is something which is not a standard GIT operation I would like to ask you guys for any advice, ideas, useful links on how I can achieve what I have just described.

To keep my question short: How to start a new repo from a branch without losing a history of that branch and its child branches?


For each branch you want to do it, create a new branch with shorter history. Branch A is the most important one. Use git checkout --orphan new_A <branching_point_SHA> to create a new branch that has no history beyond the branching point. Then delete the old A, and use git branch -m to rename new_A to A per se. Repeat for all the relevant branches. Delete all the irrelevant branches, well, because they are irrelevant and useless.

Delete all the tags that are older than the branching point. It's clear that you don't need those.

Now you should have no references to the older part of the history and you can clean it up with git gc.

Since you are not a Git beginner, you obviously must understand that it will recalculate all the commit hashes etc. Play safe.

Need Your Help

How to properly use the Android OnTouchListener and OnTouch function?

java android ontouchlistener

I have a string generator function in my Android app. I want the string generator function to be called every time there is a "tap" or "touch". The string generator function will then change the st...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.