如何删除分支并将所有提交推送到错误的存储库?
我们有几个适用于 Android 项目的 git 存储库。我们有很小的“boot”存储库和很大的“android”存储库。在开发过程中,我们的一个人将分支从“android”推送到“boot”,现在启动存储库大小为 700 MB!无论如何,现在是否可以从“启动”中完全删除错误的分支以及与其相关的所有提交?
我尝试了过滤分支和其他方法,但大多数方法都更改了错误推送后的提交编号
理论上,删除“侧面”的提交应该不是问题。该分支从未合并到“master”,并且这些提交不是任何有用提交的父级
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 repository 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 git push 从远程服务器删除分支
之后,每个人都可以在其本地存储库上运行以下命令来删除已删除的分支。
不过,在删除分支后,默认情况下,数据仍将在每个存储库中保留 2-4 周,作为防止意外数据丢失的措施。如果磁盘空间问题对您来说确实很重要,那么可以尽快将其删除,但请注意,这将删除临时保留的所有无法访问的对象,以防止意外数据丢失。
Deleting a branch from a remote server is done using
git push
After this each person can run the following command on their local repo to remove the deleted branch.
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.
删除分支是通过
注意大写的
-D
选项来完成的:这告诉 git 删除该分支,即使它没有完全合并到 master 中。完成此操作后,使用 git gc 启动垃圾收集器。那么,你应该没问题。
Deleting the branch is done by
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.