Re: Problematic git pack
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 31, 2006, 11:15 UTC
- Message-ID
- <Pine.LNX.4.63.0608311301260.28360@wbgn013.biozentrum.uni-wuerzburg.de>
- In-Reply-To
- <44F6A198.4040902@arces.unibo.it>
Hi,
On Thu, 31 Aug 2006, Sergio Callegari wrote:
> Now I am going to have the fixed archive and also a new archive, which I > restarted from the latest working copy I had of my project. > Is there any way to automatically do real "surgery" to attach one to the other > and get a single archive with all the history?
You can "graft" the new onto the old branch:
If <40-hex-chars-old> is the commit id of the youngest commit of the reconstructed branch, and <40-hex-chars-new> is the commit id of the initial commit of the newly started branch, you can put this line into .git/info/grafts:
<40-hex-chars-new> <40-hex-chars-old>
This will make git believe that the initial commit is no initial commit, but has the old head as single parent. And yes, AFAICT all git tools support this. I used this technique many times to be able to merge unrelated developments.
NOTE! This is the quickest way if you want to have the history _locally_.
If you want to be able to distribute it (or synchronize it between your laptop and PC _with git!_), you can rewrite the history by either git-rebase, or by using cg-admin-rewritehist if you are using cogito.
Unfortunately, I do not use cogito nor git-rebase, so if you want to walk that path, others have to help. (And most likely, we'd put the result into Documentation/howto/.)
Ciao, Dscho
P.S.: Of course, if you do not insist on a super clean history, you can fake a merge. Just put <40-hex-chars-old> into .git/MERGE_HEAD and commit. This will pretend that your new head and your old head were merged, and the result is the new head. This _should_ even work with git-bisect, but it is slightly ugly.