我怎样才能恢复git历史重写? [英] How can I resume a git history rewrite?

查看:204
本文介绍了我怎样才能恢复git历史重写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 git filter-branch --tree-filter 来重写一个相当大的回购的历史,并且需要几个小时。我发现git正在使用一个临时目录来存储它的中间工作。这是否意味着如果它被中断可以恢复重写?如果是这样,怎么做?



编辑 我正在做的操作是移动几个目录。这些目前在子目录中,但我现在需要它们在根目录中。



例如

  dir1 
- dir2
- dir3
- dir4

变成

  dir1 
- dir2
dir3
dir4

当然,我的目录结构比这更复杂,但这是我想要的东西的要点

挂起/恢复使用模式 - 尽管它将临时数据写入 .git-rewrite 文件夹,但根据此目录的内容没有实际支持恢复。如果您在曾经中止过滤分支操作的存储库上运行 git filter-branch ,它会要求您删除该临时文件夹,或者使用 - force 选项自己动手



潜在的问题是那么 git-filter-branch 在大回购中运行缓慢 - 如果进程速度更快,则不会尝试执行简历。所以你有几个选择:
$ b

让git-filter-branch更快一点...




  • 使用 RAM -disk - git-filter-branch 非常密集,并且运行速度更快,并且您的资源库位于RAM中。

  • 使用 - index-filter 而不是 - tree-filter - 它与tree filter相似,但doesn不检查文件树,这样会更快,但是确实需要你用git索引命令重写文件变更。

  • 使用< a href =http://debuggable.com/posts/muscles-on-demand-clean-a-large-git-repository-the-cloud-way:49ba8538-d7ac-486d-b132-0cce4834cda3 =noreferrer >云计算​​,并雇用一台速度快,时钟速度高的机器(除非你自己的命令是多线程的,否则不要担心多核心,例如 git-filter-branch 本身就是单身e-threaded)



...或使用BFG (方式更快)



BFG Repo-Cleaner 更简单,更快地替代 git-filter-branch - 在大型回购中,它是 50-150x 更快。这将需要几个小时的工作变成一个只需几分钟的

完全披露:我是作者的BFG Repo-Cleaner。


I'm rewriting the history of a fairly big repo using git filter-branch --tree-filter and it's taking a few hours. I see that git is using a temporary directory to store its intermediate work as it goes along. Does that mean it's possible to resume a rewrite if it gets interrupted? If so, how?

Edit

The operation I'm doing is moving a couple of directories. These are currently in subdirectories, but I now need them to be in the root.

e.g.

dir1
- dir2
- dir3
- dir4

becomes

dir1
- dir2
dir3
dir4

Of course my directory structure is a lot more complex than that, but that's the gist of what I'm trying to do.

解决方案

git filter-branch doesn't itself support a suspend/resume pattern of use - although it writes temporary data out to a .git-rewrite folder, there's no actual support for resuming based on the contents of this directory. If you run git filter-branch on a repository that's had a previously aborted filter-branch operation, it'll either ask you to delete that temp folder, or, with the --force option, do it itself.

The underlying problem is that git-filter-branch is slow running on big repos - if the process was much faster, there'd be no motivation to attempt a resume. So you've got a few options:

Make git-filter-branch go a bit faster...

  • use a RAM-disk - git-filter-branch is very IO-intensive, and will run faster with your repository sitting in RAM.
  • use --index-filter rather than --tree-filter - it's similar to tree filter but doesn't check out the file-tree, which makes it faster, but does require you to rewrite your file alterations in terms of git index commands.
  • use cloud computing and hire a machine with fast ram and high clock-speed (don't bother with multiple cores unless your own commands are multi-threaded, as git-filter-branch itself is single-threaded)

...or use The BFG (way faster)

The BFG Repo-Cleaner is a simpler, faster alternative to git-filter-branch - on large repos it's 50-150x faster. That turns your job that takes several hours into one that takes just a few minutes.

Full disclosure: I'm the author of the BFG Repo-Cleaner.

这篇关于我怎样才能恢复git历史重写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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