Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 438
eftshift0 Avatar asked Dec 13 '19 03:12

eftshift0


People also ask

What does git filter repo do?

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.

How do you filter a branch?

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.

How do I remove sensitive data from github?

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.

How do I filter a specific Repository in Git?

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...

What is the difference between GIT-filter-branch and Git filter-Repo?

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).

How do I get all branches of a git repository?

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.

How do I remove a file from a git repository?

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.


1 Answers

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.

like image 197
VonC Avatar answered Oct 11 '22 17:10

VonC