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
Our solution. There is a tool called git-filter-repo that you can use to rewrite your Git history and remove a file from every commit that it was involved with. You end up with a repository without certain files or folders, but everyone in the team needs to throw away their current repository and clone it again.
The basic syntax is git filter-branch <filters> branch_name . You can use HEAD or @ to refer to the current branch instead of explicitly typing branch_name . A very simple and useful filter is the subdirectory filter. It makes a given subdirectory the repository root.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.
1 Create a clone of your repository (if you created special refs outside of refs/heads/ or refs/tags/, make sure to fetch those too). ... 2 (Optional) Run git filter-repo --analyze. ... 3 Run filter-repo with your desired filtering options. ... More items...
The git filter-repo tool is an alternative to git-filter-branch which does not suffer from these performance problems or the safety problems (mentioned below). For those with existing tooling which relies upon git-filter-branch, git filter-repo also provides filter-lamely , a drop-in git-filter-branch replacement (with a few caveats).
git clone -b <branchname> <remote-repo-url>. Here -b is just an alias for --branch. With this, you fetch all the branches in the repository, checkout to the one you specified, and the specific branch becomes the configured local branch for git push and git pull . But you still fetched all files from each branch.
Oops… There is a tool called git-filter-repo that you can use to rewrite your Git history and remove a file from every commit that it was involved with. You end up with a repository without certain files or folders, but everyone in the team needs to throw away their current repository and clone it again.
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 ofrefs/remotes/origin/*
torefs/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.
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