开发者

How to delete branch with all commits pushed to wrong repository?

We have several git repositories working on Android projects. We have 'boot' repo which is small and 'android' which is huge. During development one of our guys pushed branch from 'android' to 'boot' and now boot reposi开发者_开发知识库tory size is 700 MB! Is there anyway to completely delete the wrong branch and all commits related to it from 'boot' now?

I tried filter-branch and other methods, but most of them change commit numbers made after that wrong push

In theory this shouldn't be a problem delete commits which are 'on the side'. This branch was never merged to 'master' and these commit are not parents to any useful commits


Deleting a branch from a remote server is done using git push

git push --delete boot branchname

After this each person can run the following command on their local repo to remove the deleted branch.

git remote prune boot

After the branch is removed though, the data will still linger in each repository for 2-4 weeks by default as a measure to prevent accidental data loss. If the disk space concern is really that important to you, then it can be removed sooner but take note that this will remove all unreachable objects that are being kept temporarily to prevent accidental data loss.

git gc --aggressive --prune=now


Deleting the branch is done by

git branch -D branch_name

Note the capital -D option: this tells git to delete the branch even if it's not fully merged into master.

After doing that, fire up the garbage collector with git gc. Then, you should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜