git - How do you remove a branch and all of its history locally and remotely? -
i have git branch need nuke traces of. think need like
git filter-branch --index-filter 'git -d <branch>' --tag-name-filter cat -- --all
or maybe
git filter-branch --index-filter 'git rm --cached *' --tag-name-filter cat -- <branch>
then would
git push -f origin :<branch>
i'm hesitant try them without knowing sure they'll or if they'll work.
let's want nuke evilbranch
.
you want delete of branch's history. technically includes initial commit, more commits want. first, identify commit consider first commit of branch. let's it's 666bad
. need find references it. run
git branch -a --contains 666bad git tag --contains 666bad
now delete them all. can either use git commands, or go .git/refs
.
do on every computer might have file.
make sure not in detached head.
now can kill commits, , therefore code, no longer referenceable (from this github link):
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin git reflog expire --expire=now --all git gc --prune=now
again, should done on each computer.
finally, use this on each computer.
note: 666bad
first commit after evilbranch
split wherever came from, i.e., first commit evilbranch
.
Comments
Post a Comment