{"thread":{"id":"11774","subject":"lost history with directory move?","startedAt":"2008-01-29T01:22:42Z","lastAt":"2008-01-29T02:21:41Z","messageCount":2,"participants":["Perrin Meyer","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"66770","messageId":"66024.57523.qm@web52812.mail.re2.yahoo.com","threadId":"11774","inReplyTo":null,"subject":"lost history with directory move?","fromName":"Perrin Meyer","fromEmail":"perrinmeyer@yahoo.com","sentAt":"2008-01-29T01:22:42Z","receivedAt":"2008-01-29T01:22:42Z","isPatch":false,"sender":{"key":"perrinmeyer@yahoo.com","avatar":null},"body":"\n\nI'm confused about history and directory renaming. Where did my history go? \n\nI have a git repo with a doc/ directory, which I renamed to Documentation/ \n\n$ mv doc/ Documentation/\n$ git commit -a \nwhere I see a lot of deletes\n$ git push\n\n$ git add Documentation/\n$ git commit -a\nand I see that a all my doc files added, as expected. \n$ git push \n\nBut when I got to look at the history of the Documentation/ directory\n\n$ git log Documentation/\n\nI only see one commit message \n\neven if I do a \n\n$ git log --follow Documentation/\n\nI don't see my history.\n\nEven if I try a single file\n\n$ git log --follow README\n\nI only see the single rename commit, not any history. \n\nWhat did I do wrong?  \n\nI'm guessing, in hindsight, that I probably should have done\n\n$ mv doc/ Documentation/\n$ git add Documentation/\n$ git commit -a \n\nbut is there anyway to get my history back given what I have done? \n\nThanks for the help.  I'm using git version 1.5.3.8 \n\nPerrin Meyer \n"},{"id":"66774","messageId":"20080129022141.GF24004@spearce.org","threadId":"11774","inReplyTo":"66024.57523.qm@web52812.mail.re2.yahoo.com","subject":"Re: lost history with directory move?","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-01-29T02:21:41Z","receivedAt":"2008-01-29T02:21:41Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Perrin Meyer <perrinmeyer@yahoo.com> wrote:\n> $ mv doc/ Documentation/\n> $ git commit -a \n> where I see a lot of deletes\n> \n> $ git add Documentation/\n> $ git commit -a\n> and I see that a all my doc files added, as expected. \n> \n> But when I got to look at the history of the Documentation/ directory\n> \n> $ git log Documentation/\n> \n> I only see one commit message \n> \n> $ git log --follow Documentation/\n\n--follow only works on a single file.  So you cannot use\nit for an entire directory.\n \n> $ git log --follow README\n> \n> I only see the single rename commit, not any history. \n\nRight, because the file came into existance in that commit and we\ncannot find any deleted path in that same commit that is \"highly\nsimilar\" to the file now called Documentation/README.  So we don't\ncall it a rename.\n \n> I'm guessing, in hindsight, that I probably should have done\n> \n> $ mv doc/ Documentation/\n> $ git add Documentation/\n> $ git commit -a \n\nCorrect.  Rename detection works by looking for an add/delete pair\n_in the same commit_ that have file content that is higly similar\nbetween the two paths.  You broke that by doing the two changes in\ntwo different commits.\n \n> but is there anyway to get my history back given what I have done? \n\nI can't think of one other than to squash the two commits together\nwith a tool like `git rebase -i` and then force push it back to\nyour upstream repository.  Note that doing this would change the\ncommit SHA-1 names so anyone who has built on top of these changes\nwould also need to rebase their changes.\n\n-- \nShawn.\n"}]}