git filter-repo: can it be used on a specific branch?
Asked Answered
B

2

13

I'm reading about what git filter-repo can do because I want to do a small experiment with it.... I have this repo where I only want to get the history of one directory from, say.... master..... but I don't want to work on master. I would like to create a new branch, say filter-repo-test and let git filter-repo run its magic on this branch alone. I'm reading the manual but I don't see an option to specify only a given branch. Is it possible?

https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html

Beaming answered 13/12, 2019 at 3:2 Comment(0)
P
12

The 'Miscellaneous Options' includes --refs

--refs <refs+>

Limit history rewriting to the specified refs. Implies --partial.
In addition to the normal caveats of --partial (mixing old and new history, no automatic remapping of refs/remotes/origin/* to refs/heads/*, etc.), this also may cause problems for pruning of degenerate empty merge commits when negative revisions are specified.

And... it will move tags, as I documented in "Git Subdirectory Filter with tags", which does uses --refs, as an example.


As Ryan Wheale notes in the comments:

You should be able to use the branch name to limit the filtering to the branch.
Again, take note of the caveats of --partial.

--refs filter-repo-test
Pole answered 13/12, 2019 at 4:50 Comment(1)
Just a note for others: you should be able to use the branch name to limit the filtering to the branch. Again, take note of the caveats of --partial: --refs filter-repo-testAllegorical
B
0

Never mind, I just found it. It was right under my nose. It is defined with --refs

Beaming answered 13/12, 2019 at 3:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.