Separate each commit by file?

I have accumulated a lot of git for my project. As a first step in clearing the repo up, I would like to split each commit into two commits: one that only applies to a specific file / some / directory / file, and the other that deals with everything else.

Since the git story is quite long, I would like to avoid this manually.

Some approaches that I was thinking about (but have not really tried):

  • using git rebase --exec with a script that does the splitting.
  • using filter-branch . (not familiar with this tool)

However, since this seems like a fairly common problem to me, it seemed to me that I would check here before trying to invent a wheel. Is there any automated way to do this?

+6
source share
1 answer

You are on the way, what you have tried is the way to do it.
As you know, you have 2 main options:


git rebase -i aka: squash (manual procedure)

 // Manipulate any commit by editing it and commitign again git rebase -i HEAD~X 

Since the git story is quite long, I would like to avoid this manually.

git filter branch


Example

 // Remove any given file from commits // Now you can commit it again into a new commit git filter-branch --tree-filter 'rm -f <file name> HEAD 
+4
source

All Articles