Is there any difference between these two commands?
git subtree split --prefix=some_subdir -b some_branch
and
git filter-branch --subdirectory-filter some_subdir some_branch
I would like to use git filter-branch
instead of git subtree
because I also want to delete some files in the new branch, but I am worried that this guarantee, which is true for git subtree
, might not be valid for git filter-branch
:
Repeated splits of exactly the same history are guaranteed to be identical (ie. to produce the same commit ids). Because of this, if you add new commits and then re-split, the new commits will be attached as commits on top of the history you generated last time, so 'git merge' and friends will work as expected.
filter-branch
definitely does not give any such guarantee, so when using it you are definitely on the hoping side. But the subdirectory filter has exactly reproducible results and filter-branch
does not touch the commit information (commit and author timestamp and person). As this is the information the commit sha is created from, filter-branch
should generate the same history again.
That’s all you going to get as long as filter-branch
does not start making any guarantees, and that seems unlikely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With