简体   繁体   English

GIt:使用BFG从存储库中删除了几个文件,并且提交差异很大

[英]GIt: Removed several files from repository with BFG and there are enormous commit diffs

I recently removed several large files from a repository using BFG --delete-files , and the output appeared to be what I expected. 我最近使用BFG --delete-files从存储库中删除了几个大文件,输出似乎是我所期望的。 The correct files and sizes were reported as deleted from the repo and the local size reflects these removals. 正确的文件和大小被报告为从存储库中删除,本地大小反映了这些删除。

However, when I upload and compare to master, it reports that there is a huge difference and it affects several hundred commits. 但是,当我上传并与master进行比较时,它报告存在巨大差异,并且影响了数百次提交。 I'm not sure what to make of this or how to understand it; 我不知道该怎么做或如何理解它。 it is too much to go through. 太多了。 I understand removing the files will restructure the repo, but how can I be sure what was intended actually happened in the diff? 我知道删除文件将重组存储库,但是如何确定差异中实际发生了什么?

It depends on the nature of the diff seen in all those files. 这取决于在所有这些文件中看到的差异的性质。

For instance, if they are EOL differences (end-of-lines), that could means the BFG commit-rewritten process was done locally with a config core.autocrlf which might have change eol for all the files (in addition of removing some of them). 例如,如果它们是EOL差异(行尾),则可能意味着BFG提交重写过程是使用config core.autocrlf在本地完成的,可能对所有文件都有eol更改(除了删除了一些他们)。
Once pushed, all the other files would be shown as "different". 推送后,所有其他文件将显示为“不同”。

It's caused by java -jar bfg.war --delete-files filename will delete the the specified file from the whole commit histories for all branches, but you only push one branch to remote . 它是由java -jar bfg.war --delete-files filename引起的java -jar bfg.war --delete-files filename将从所有分支的整个提交历史记录中删除指定的文件,但是您只能将一个分支推送到remote

Assume the commit history as below before using BFG to delete files as below: 在使用BFG删除文件之前,假定如下的提交历史:

…---A---B---C---D  master, origin/master
         \
          E---F  mybranch, origin/mybranch

When you compare master branch with mybranch , the related commits are C , D , E and F . 当您将master分支与mybranch进行比较时,相关的提交为CDEF

And assume the delete-files is test.txt , and it only exist in commit B and E . 并假定delete-files是test.txt ,并且它仅存在于提交BE When you execute 执行时

java -jar bfg.war --delete-files test.txt

The commit history will be: 提交历史将为:

…---A---B'---C'---D'  master, origin/master
         \
          E'---F'  mybranch, origin/mybranch

Note: it rewrite the commits not only for local branches ( master and mybranch ), but also re-point the tracking branches ( origin/master and origin/mybranch ). 注意:它不仅重写本地分支的提交( mastermybranch ),而且还重新指向跟踪分支( origin/masterorigin/mybranch )。

If you do git fetch after that, you will find the local branches with their tracking branches are diverged: 如果之后执行git fetch ,则会发现本地分支及其跟踪分支是分开的:

        E---F    origin/mybranch
       /
      B---C---D  origin/master
     /     
…---A---B'---C'---D'  master
         \
          E'---F'  mybranch

While if you only force push mybranch to remote repo (not force push master branch), the commit history on remote repo will be: 而如果你只力推mybranch远程回购(不力推master分支),提交远程回购的历史将是:

      B---C---D  master
     /     
…---A---B'---E'---F'  mybranch

So when you compare mybranch with master branch again, the relate commits will contains B , C , D , B' , E' and F' . 因此,当您再次将mybranchmaster分支进行比较时,相关提交将包含BCDB'E'F'

And if you also force push local master btanch to remote, the count of related commits should be the same when you compared when using BFG. 而且,如果您还强制将本地master密码推送到远程,则在使用BFG进行比较时,相关提交的计数应该相同。

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

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