简体   繁体   English

正确使用BFG回购清洁剂

[英]Correct Usage of BFG Repo Cleaner

The BFG Repo Cleaner site gives an example of using the tool as follows to clean up a repository: BFG Repo Cleaner站点提供了使用该工具清理存储库的示例,如下所示:

  1. Clone a fresh copy of your repo. 克隆您的存储库的新副本。

     $ git clone --mirror git://example.com/some-big-repo.git 
  2. Run BFG to clean up your repo. 运行BFG清理您的仓库。

     $ java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git 
  3. Use git gc to strip out the unwanted dirty data 使用git gc去除不需要的脏数据

     $ cd some-big-repo.git $ git reflog expire --expire=now --all && git gc --prune=now --aggressive 
  4. Push changes back up to the remote 将更改推回远程

     $git push 

I understand the head branch is protected so any file in the head branch that is larger than 100M will still be there. 我知道head分支受到保护,因此head分支中大于100M的任何文件仍然会存在。 If I run this tool as described I will lose any history of said 100M file correct? 如果我按照说明运行此工具,我会丢失所说100M文件正确的任何历史记录吗? So if there is an old version of that file in an old commit it's gone and I will not be able to use it in it's previous state....correct? 因此,如果在旧提交中存在该文件的旧版本,则该文件将消失,而我将无法在其先前状态下使用它。...正确吗?

Also, I have a coworker that stated the following and I am wondering if it is true: 另外,我有一位同事说了以下内容,我想知道这是否成立:

If you push back to the repository that was mirrored in TFS the changes to your pack file won't be reflected on the remote and future clones 如果您推回TFS中已镜像的存储库,则对包文件的更改将不会反映在远程克隆和以后的克隆中

You have to create a new repository in TFS and push the mirror there for the remote to pick of the pack file changes. 您必须在TFS中创建一个新的存储库,然后将镜像推到那里,以供远程用户选择打包文件的更改。

Any file still present at the HEAD of the repo will be preserved, including the history. 回购文件的HEAD上仍然存在的任何文件都将被保留,包括历史记录。 It's to protect you from making mistakes. 这是为了防止您犯错误。 The idea is that you should explicitly delete the file, commit the deletion, then clean up the history to remove it. 这个想法是您应该显式删除文件,提交删除,然后清理历史记录以将其删除。

TFS does not gc its repos; TFS不gc其回购; your colleague is correct. 你的同事是正确的。 See Team Foundation Server 2015 (tfs2015) run git gc --prune=now on orgin/remote for confirmation. 请参阅Team Foundation Server 2015(tfs2015)在原始/远程上运行git gc --prune = now进行确认。

Shortly I also used the BFG Repo Cleaner to delete some folders from an git repo at TFS. 不久,我还使用BFG Repo Cleaner从TFS的git repo中删除了一些文件夹。

If you want to modify also the head, use parameter --no-blob-protection 如果您还想修改头部,请使用参数--no-blob-protection

Obviously, in the cleaned (old) commits the files which you cleaned are missing. 显然,在已清除(旧)中,提交的内容将丢失。 The commits are still there but the file is missing in each corresponding commit. 提交仍然存在,但是每个相应的提交中都缺少文件。 You will not be able to see the file history. 您将无法查看文件历史记录。

For safety reasons I would always rename the old repo and create a new one. 出于安全原因,我将始终重命名旧仓库并创建一个新仓库。 Probably even with another repo Name so that my co-workers can't get the wrong repo merged into their working copy. 甚至可以使用另一个回购名称,这样我的同事就不会将错误的回购合并到他们的工作副本中。

If you really want, it is possible to git push --all -force and rewrite the complete history on the TFS repo. 如果确实需要,可以使用git push --all -force并重写TFS存储库上的完整历史记录。 But then the old history is gone. 但是后来,旧的历史消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM