Is it possible to replace files from different commits in git with a "unified" patch?

35 views Asked by At

I have a git repository with different tags/commits and I want to replace a Makefile (it is different in each version).

In all these versions with my own Makefile.
Is it possible to write only one patch-file that can be applied to all of these commits/tags that will "delete" the individual Makefile and "insert" mine?

1

There are 1 answers

0
CodeWizard On BEST ANSWER

The simple answer is not.

Why can't you?

If you wish to update multiple commits you have to update them each one separately due to the way in which git store the date (too long to explain here how)

What can you do?

You can write a script to do it.

The script should look something like:

# loop on your commits and update the desired file
git filter-branch --index-filter 'mv "new-file" "old_file"' HEAD

Note:

You can use --tree-filter and --index-filter with git filter-branch.
--index-filter is faster and will update your index file