Skip to content

How to delete commits (and git branches) completely ? #4709

Answered by simonmichael
simonmichael asked this question in Q&A
Discussion options

You must be logged in to vote

Thank you, --expire=now (or --prune=now on the git side) was another important clue. And noted about evolog.

For the record, I got these stale branches cleaned out in this way:

  1. Take advantage of jj to save a list of the branches to be deleted. Eg: jj log --no-graph -r 'bookmarks() ~ person(simon)' -T 'bookmarks++"\n"'
  2. Give names to any unnamed heads created with jj: jj bookmark create ...
  3. Discard jj state, in the simplest way: rm -rf .jj
  4. Delete each branch with git: for b in ...; do git branch -D $b; done
  5. Also delete the "keep" references created by jj: gsed -i '/\/keep\//d' .git/info/refs; gsed -i '/\/keep\//d' .git/packed-refs
  6. Check one or two hashes to see if they're still referenced: r…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@simonmichael
Comment options

@simonmichael
Comment options

@yuja
Comment options

yuja Oct 25, 2024
Maintainer

@simonmichael
Comment options

Answer selected by simonmichael
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants