git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.

Previous: Sergio CallegariNext: Nicolas Pitre
Message 2 of 4 in “Re: Problematic git pack”
  1. Sergio CallegariAug 31, 2006
  2. Johannes SchindelinAug 31, 2006
  3. Nicolas PitreAug 31, 2006
  4. Linus TorvaldsAug 31, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.