使用bazaar删除文件历史记录
有人将所有二进制文件提交到我们的集市主干中,我想摆脱它。 `bzr del file' 仅删除当前修订版中的文件,但不删除文件的历史记录。
有没有一种方法可以删除文件历史记录,这样我们就不必下载数百 MB 的数据?
Someone committed all binaries to our bazaar trunk, and I want to get rid of it.
`bzr del file' only deletes the file from the current revision, but not the history of the file.
Is there a way we can remove the file history so that we don't all have to download hundreds of MBs of data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有两种方法。但是您需要准备好重新创建部分(甚至完整)分支历史记录,因此删除文件后当前(本地)分支将与新分支不兼容。
1)手动方式。您可以在添加大文件之前创建分支的副本以进行修订。然后,您需要半手动地重新提交进一步的修订并排除大文件。使用 bzr-rewrite 插件(以前的 bzr-rebase)中的
replay
命令来重播那些没有对大文件进行更改的修订。并使用merge -cN
进行大文件更改的修订,手动删除这些文件并提交。因此,您将保持大部分历史记录完好无损,并为分支的其他文件保留唯一的文件 ID。2) 使用
bzr-fastimport
插件通过bzr fast-export
命令将历史记录导出为快速导入流。然后使用 bzr fast-import-filter -x FILE 命令过滤掉大文件。最后使用 bzr fast-import 命令重新创建没有大文件的新分支。此方法将破坏您的所有历史记录,并且您的所有文件将获得新的文件 ID,因此您的新分支将与旧分支完全不兼容。无论如何,如果您的共享存储库内部包含大文件历史记录,则需要创建新的空共享存储库并将新的过滤分支放在那里。
There is 2 ways. But you need to be ready that you will re-create the part (or even full) of your branch history, so your current (local) branches will become incompatible with new branch after deleting the file.
1) Manual way. You can create a copy of your branch to revision just before big files have added. Then you need semi-manually re-commit your further revisions and exclude big files. Use
replay
command from bzr-rewrite plugin (former bzr-rebase) to replay those revisions where no changes to big files present. And usemerge -cN
for revisions where changes to big files are present, manually delete these files and commit. Thus you will keep most of your history intact and will keep unique file ids for other files of your branch.2) Use
bzr-fastimport
plugin to export your history as fast-import stream withbzr fast-export
command. Then filter out big files withbzr fast-import-filter -x FILE
command. And in the end re-create new branch without big files withbzr fast-import
command. This method w3ill destroy all your history and all your files will get new file ids, so your new branch will be totally incompatible with old branch.In any case, if you have shared repository with big files history inside you need to create new empty shared repository and put your new filtered branch there.
如果二进制文件是在上次提交中添加的,您可以取消提交。
这将使您的工作树处于您编写“bzr commit”之前的状态。然后删除文件并重新提交。
有关更多详细信息,请查看关于撤消错误的集市文档。
您可以使用 -r 选项在一次操作中撤消多次提交:
bzr uncommit -r -4
如果您不关心修订历史记录,则可以使用其他选项:
您可以导出分支 (
bzr export DESTINATION
),然后创建新的主干。导出命令将仅导出头存储库,没有任何历史记录。
If the binary files were added in the last commit, you can uncommit it.
This will leave your working tree in the state it was just before you wrote "bzr commit". Then delete the files and re-commit.
Check the bazaar doc on undoing mistakes for more detail.
You can use the -r option to undo several commits in one operation:
bzr uncommit -r -4
Other option, if you do not care of the revision history:
You can do an export of your branch (
bzr export DESTINATION
) and then create a new trunk.The export command will simply export the head repository, without any history.
我正在寻找一种方法来摆脱 CVS/ 目录,这些目录使其成为我所有 bzr 提交的方式。我是 bzr 的新手,所以当时我还不确定如何处理它们。 (在工作中,中央存储库是 CVS,但我在本地使用 bzr 来帮助我)。
这是我为摆脱项目中的一些 CVS 目录所做的示例,它并不意味着完美,而是一个快速破解:)
你在 dir /home/user/dev 中有一个名为“projAAA”的项目
导出当前 bzr 项目(用于 bzr 导入)
将该导出移至空目录(由于某种原因,过滤器会查看其运行的其他目录)
Script_1
该脚本采用导出并过滤您使用 -x 提供的所有内容
不幸的是 -x 似乎不适用于通配符,因此您必须给出准确的值/路径/文件
它在 ~/tmp/rewrite 中运行
现在目录“new.import”将包含除您过滤掉的内容之外的所有内容。
运行以下脚本来查看该新导入的整个修订历史记录,以查找可能仍然存在但您不想要的内容,您应该在 Script_1 中添加另一个 -x 值(然后我将重新运行该值,直到我满意为止)
Script_2 :
在 ~/tmp/rewrite 中运行此命令:
如果您现在查看 search.out 内部,您可以看到搜索找到的内容,然后将它们添加到之前的脚本中,直到您满意为止。
所以,本质上,我会重复这样做几次,直到我满意为止;
条目
I was looking for a way to get rid of CVS/ dirs that made it's way into all my bzr commits. I'm new to bzr, so at the time, I wasn't yet sure how I was going to handle them. (At work the central repo is CVS, but I use bzr locally to help me).
Here is an example of what I did to get rid of some CVS dirs in my project, it's not meant to be perfect, but a quick hack :)
You have a project called 'projAAA' in dir /home/user/dev
Export the current bzr project (for bzr import)
Move that export to an empty dir (the filter for some reason looks at other dirs where it's run)
Script_1
This script takes the export and filters everything you supply with -x
Unfortunately -x doesnt seem to work with wildcards, so you have to give exact values/paths/files
It runs in ~/tmp/rewrite
Now the dir "new.import" will contain everything but what you've filtered out.
Run the following script to look through the entire revision history of that new import for stuff that might still be there, that you dont want, for which you should add another -x value in Script_1 (which I will then rerun until Im happy)
Script_2:
Run this in ~/tmp/rewrite:
If you now look inside search.out, you could see what the search has found, and then add those to the previous script until you're happy.
So, in essence, I re-do this a couple of times until I'm happy;
entries