从位桶历史记录中删除文件夹 [英] Remove Folder from bitbucket history

查看:111
本文介绍了从位桶历史记录中删除文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git仓库的新手.我在bitbucket中有2gb的限制,并且我在误操作中添加了一个1.5 gb的images文件夹并推送了代码.

I am new to git repository. I have a 2gb limit in bitbucket and bymistake I added one images folder of 1.5 gb and pushed the code.

现在,位桶大小为1.8gb.要从历史记录中删除该文件夹,请按照以下步骤操作.

Now the bitbucket size is 1.8gb. To remove the folder from history I followed these steps.

从git/GitHub的历史记录中删除文件夹及其内容

git filter-branch --tree-filter 'rm -rf import/images' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git 
update-ref -d
echo import/images/ >> .gitignore
git add .gitignore
git commit -m 'Removing images from git history'
git gc
git push origin master --force

我按照以下步骤操作,并检入了以前的提交内容,然后删除了该文件夹.但是git count-objects -v仍然提供1.8gb的大小包

I followed these steps and checked in my previous commits and the folder is removed. but git count-objects -v still gives the size-pack of 1.8gb

在bitbucket存储库设置中,它仍然显示1.8gb

Also in the bitbucket repository settings its still showing 1.8gb

我想念什么吗?

推荐答案

您必须转到bitbucket页面才能删除文件.

You have to go to bitbucket page in order to delete a file/files.

  1. 进入您的仓库,
  2. 选择来源(左侧面板)
  3. 选择分支机构
  4. 找到您的文件夹
  5. 进入并删除那里的所有图像(右上角有3个可点击的点,这是删除选项)

您不能像这样删除文件夹(由于某些原因,bitbucket只能手动删除文件和删除分支),但是您始终可以手动清空文件夹,并在下一次git push中通过控制台将其删除.

You can't delete the folder like that (for some reason bitbucket allows only file delete and branch delete manually) but you can always empty the folder manually and remove it through console in the next git push.

警告.此操作类似于硬删除",因此在使用时要格外小心,如果可以使用git命令,请不要使用它.

Caution. This work like a "hard delete" so be extra careful when you use it, and don't use it if you can use git commands.

编辑

 git gc --prune=now  //accepts date

看看这个链接,有很多选项可能适合你的问题.

Have a look at this link there are quite a few options that may suit your problem.

另一种方法是git filter-branch --force.有关此命令的更多信息,您可以在此处找到.该命令专门用于重写" git历史记录,因此可以完成您的工作.这很棘手,但可以.

Another approach is the git filter-branch --force. More about this command you can find here. This command is specifically for "rewriting" git history so it will do your job. It's tricky but it will do.

最后一种也是最后一种方法(老实说,从未使用过这种方法)是3rd party软件(由于atlassian甚至在其文档中也包括了它,因此确实很安全),但是它在Java中,因此首先需要安装Java才能运行控制台中的java命令.我看到了您的php标记,因此我只是为了考虑一下就将其保留了下来.我在此处留下了链接.

One last and final approach (never used this one to be honest) is 3rd party software (Really secure as even atlassian includes it in their documentation) but is in java so first you will need to install java in order to run a java command in your console. I saw your php tag so i just leave this as last just to concider it. I leave ths link here.

这篇关于从位桶历史记录中删除文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆