Comments (6)
The performance cost of updating more branches, even hundreds more, tends to be quite small. filter-repo (via fast-export and fast-import) write a modified version of each commit and then update each branch pointer to the newly rewritten commits. The only way handling hundreds of extra branches would add significantly to the overhead is if those branches didn't share common history (or only shared a little) with the branches you care more about, and the "extraneous" branches had lots of unique commits. Typically, all branches share a bunch of common history and you are rewriting all those commits anyway, so the cost of including more branches (some of the repositories I've worked on had thousands or tens of thousands of refs) is pretty small.
If you really just don't want to see them, though, you can definitely prune them either before or after doing the history rewrite. I tend to just open up the .git/packed-refs file and start deleting lines, but that's because I'm not afraid to muck with git internal storage whose format may change in the future. You may want to instead use git update-refs
for this job, perhaps with the --stdin flag so you can just give it a whole bunch of delete refs/remotes/origin/CRUFTY_BRANCH_N
lines.
Hope that helps; let me know if anything isn't clear.
from git-filter-repo.
git update-ref -d <refname>
will let you delete a ref (similar to branch -d
or tag -d
, but you need to specify fully qualified refnames, such as refs/heads/master instead of just master). You can get help with git update-ref --help
, but a brief intro:
update-ref can also batch delete refs if you feed it a bunch of input, e.g.
printf "delete refs/heads/master\ndelete refs/heads/maint\n" | git update-ref --stdin
If you wanted to delete all but a few refs, I'd run
git show-ref | sed -e s/[0-9a-f]*/delete/ >commands-to-delete-all-refs.txt
then edit commands-to-delete-all-refs.txt and remove the lines corresponding to refs you want to keep, then run
cat commands-to-delete-all-refs.txt | git update-ref --stdin
from git-filter-repo.
Hmm.. didn't get any notification of this response, apologies. Make sense re: the performance aspect... explanation understood 👍🏼
Could you please elaborate on how to use the update/delete refs command? That's not something i have used previously.. all the branches i need to prune have irregular names.. i am keen to some sort of prune everything except these specific branches
can the command be inverted?
While you reply.. i shall go check the doco! 🙂
from git-filter-repo.
Nice. Had a play with w. the update-ref
cmd, seems pretty self explanatory and i think i follow what you mean with --stdin
but will check out your cmd above.
I don't want to mess with my original repo, so i think i'm just gonna do the filter-repo
, which brings everything down.. and then get rid of the refs/heads/
..
Not sure what to do with the refs/tags
, does the filter-repo
ignore commits and tags for tags??
from git-filter-repo.
Righto, got this doing what i think i want it to..
- Clone to new location
- Do my filtering, which works fine, and brings down all
refs/remotes/origin/
to end up inrefs/heads/
- Lose everything in
refs/heads/
other thandevelop
,master
,release
- Push the remaining branches to a new origin 👍🏼
Do i need to explicitly do anything w. refs/replace/
at all? I am thinking that the answer is no, as they must have been merged.. but not 100%
Also , a question still remains about the refs/tags/
though.. but will try to do some more research on that..
from git-filter-repo.
The refs/replace/ merely provide a mapping from old commits IDs to new commit IDs, allowing you to pass old commit IDs to git commands and have git be able to bring up the new commits. It's there to help facilitate the transition, for teams that need it. If you can do a clean switchover to new IDs, then you can just drop those.
As for the tags, yeah git-filter-repo will rewrite those too just like branches. Whether you want or need the tags that are in your project, is completely up to your project.
from git-filter-repo.
Related Issues (20)
- Update submodule hashes?
- Renaming paths into pre-existing path causes double-nested paths (sometimes)
- Keep last 3 months of package-lock.json diffs only HOT 1
- Question: prune lfs files
- remark: Pity that this tool can't run scripts/programs and it is not clearly stated HOT 1
- minor: Logic error with `_commits_referenced_but_removed` on a GitHub Gist web url in commit message 😂
- Crash when path contains emoji
- Question: Recommended way to log the usage of git filter-repo and related changes? HOT 1
- Callback that gives both filename and blob
- Breaking change in git 2.43 or 2.44 HOT 1
- lint-history: --refs argument not working at all
- Test suite succedes with Python 3.11 but has multiple failures with Python 3.12 HOT 4
- Turns out my assumption was wrong: `git lfs migrate export --everything --include="*"` does rewrite the whole history, across all branches, reinjecting all the large files' consecutive versions ([see here](https://github.com/git-lfs/git-lfs/issues/910#issuecomment-551566315)). Awesome! HOT 1
- Support for SHA256
- FR: Filter into new repo
- clean-ignore of filter-repo-demos does not handle utf-8 characters
- Trouble with Lock File HOT 1
- Really-43e2c HOT 2
- > main HOT 1
- Renaming path and then renaming it back to the original name deletes path rather than renaming it HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git-filter-repo.