keep commits only for subset of files in git

Viewed 89

I would like to achieve the following:

  1. keep all the change history(or commits) for the files I selected. Some of the files were renamed and some also were moved from another directories.
  2. I would like to remove all the commits that are unrelated to the files I selected from the git log

I tried different approaches, for example this, but it would not keep the whole history

It would work for me even if I have to process files one by one. I do not have many of them. I just cannot find a way to preserve all commits for the files that were renamed and/or moved.

Thanks in advance

0 Answers
Related