Giter VIP home page Giter VIP logo

Comments (6)

newren avatar newren commented on June 25, 2024 1

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.

newren avatar newren commented on June 25, 2024 1

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.

m1nkeh avatar m1nkeh commented on June 25, 2024

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.

m1nkeh avatar m1nkeh commented on June 25, 2024

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.

m1nkeh avatar m1nkeh commented on June 25, 2024

Righto, got this doing what i think i want it to..

  1. Clone to new location
  2. Do my filtering, which works fine, and brings down all refs/remotes/origin/ to end up in refs/heads/
  3. Lose everything in refs/heads/ other than develop, master, release
  4. 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.

newren avatar newren commented on June 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.