简体   繁体   中英

Remove the whole history of a specific branch from git repository

I would like to remove a branch from my repository and also from the history so the .git folder will get smaller. The branch was never merged to master.

I already tried to remove the branch with

git branch -D <branch name> and then to run

 git gc --prune=now --aggressive

I also tried

git reflog expire --expire=now --all

but nothing worked. the folder .git size didn't change at all and the commit didn't disappear, I could still see them with:

 git show <commit hash>
  • everything i tried was in local repository.

Is there any way to do this? if so, can you write the exact way to do it?

Its also possible i did something wrong with those commands. so please write it detailed.

Thank you.

Radical way:

Try to clone only master branch to new repository. Fetch some necessary branches from old repository. Delete old repository, rename new to old.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM