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.
Assume the commit history as below before using BFG to delete files as below:
…---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
.
And assume the delete-files is test.txt
, and it only exist in commit B
and E
. 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
).
If you do git fetch
after that, you will find the local branches with their tracking branches are diverged:
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:
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'
.
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.