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

Re: lost history with directory move?

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 29, 2008, 02:21 UTC
Message-ID
<20080129022141.GF24004@spearce.org>
In-Reply-To
<66024.57523.qm@web52812.mail.re2.yahoo.com>
Perrin Meyer <perrinmeyer@yahoo.com> wrote:
Show 15 quoted lines
> $ mv doc/ Documentation/
> $ git commit -a 
> where I see a lot of deletes
> 
> $ git add Documentation/
> $ git commit -a
> and I see that a all my doc files added, as expected. 
> 
> But when I got to look at the history of the Documentation/ directory
> 
> $ git log Documentation/
> 
> I only see one commit message 
> 
> $ git log --follow Documentation/
--follow only works on a single file.  So you cannot use
it for an entire directory.
 
> $ git log --follow README
> 
> I only see the single rename commit, not any history. 
Right, because the file came into existance in that commit and we
cannot find any deleted path in that same commit that is "highly
similar" to the file now called Documentation/README.  So we don't
call it a rename.
 
Show 5 quoted lines
> I'm guessing, in hindsight, that I probably should have done
> 
> $ mv doc/ Documentation/
> $ git add Documentation/
> $ git commit -a 
Correct.  Rename detection works by looking for an add/delete pair
_in the same commit_ that have file content that is higly similar
between the two paths.  You broke that by doing the two changes in
two different commits.
 
> but is there anyway to get my history back given what I have done? 

I can't think of one other than to squash the two commits together with a tool like `git rebase -i` and then force push it back to your upstream repository. Note that doing this would change the commit SHA-1 names so anyone who has built on top of these changes would also need to rebase their changes.

-- 
Shawn.
Previous: Perrin Meyer
Message 2 of 2 in “lost history with directory move?”
  1. Perrin MeyerJan 29, 2008
  2. Shawn O. PearceJan 29, 2008

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.