0

I used to have a single repository:

my-project/
    app/
        common/
            logger.js
        foo/
        bar/
        index.js

The logger.js file located in my-project/app/common used to be located in my-project/app. It has been moved with git mv. The command git log -- app/common/logger.js only returns the history since it has been moved, all the history linked to its previous location has been lost. However this lost history can be accessed using git log --follow -- app/common/logger.js

I have split this repo into 4:

  • my-project-common: contains my-project/app/common
  • my-project-foo: contains my-project/app/foo
  • my-project-bar: contains my-project/app/bar
  • my-project: contains my-project/app/index.js

I achieved this with git filter-branch and it worked.

Problem: When moving my-project/app/common into my-project-common/, the history of logger.js only contains the history linked to its previous location (ie: my-project/app/common). The history linked to the location my-project/app is not accessible, even with --follow.

Question: How to preserve the full history of logger.js?

Simon
  • 1,679
  • 4
  • 21
  • 37

1 Answers1

1

There is no other way to view the history beside the --follow flag.

The only other way i can think of is to split the repo into 4 different repositories and then merge them back again.


Another way is to split the repositories to separate ones and use the pars as submodules. Again as before this solution require to split the repo.

Summary

The only way to see full history of removed file is to use the git log --follow.

The other way is to split the repository to different repositories and use each part as separate repo or to combine them back to the original repo.

How to split repository (folders based)

Read this answer for full description.
make new git branch containing full history of only some files

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Actually, the `--follow` flag does not return anything once split into the new repo. – Simon Apr 19 '16 at 12:44
  • What exactly did you do? you should have the log. if you don't you can always use `git filter-branch` once you split the branches and to move the files manually. But if you split it using the split command as explained in the answer it should work an you should see the content. – CodeWizard Apr 19 '16 at 12:46
  • I did exactly what I said. And when thinking about it, it's normal that `git log --follow` does not show the previous location history since `--follow` is just sugar that concatenates the history of multiple files (even if these no longer exist). Though it does not solve my problem. – Simon Apr 19 '16 at 12:57
  • Ok, so you the only way is to use the `git log --follow` – CodeWizard Apr 19 '16 at 13:00