rtyley / bfg-repo-cleaner

Removes large or troublesome blobs like git-filter-branch does, but faster. And written in Scala
https://rtyley.github.io/bfg-repo-cleaner/
GNU General Public License v3.0
10.95k stars 540 forks source link

I'm trying to follow a process for clean up the repo using BFG but same is not getting reflected for master branch after push the branches are getting reflected #310

Open amrutaDesai opened 5 years ago

amrutaDesai commented 5 years ago

I have some folders in repo which should be cleaned up along with its history, I'm following a process as mentioned below, with the help of guide lines provided at BFG user guide lines

FYI, I have master and 2 sub branches from master say feature/1190/branch1 & feature/880/branch2

  1. I have a git folder like "home/user/git" and created a folder with "project_Name" inside the same,
  2. I have also put the bfg-1.13.0.jar inside the project_Name folder.
  3. At the same location I have my project cloned in the normal way and now I'm cloning for bare repo with flag --error, so in the same folder of project_Name I have dummy-repo-to-test-removal-of-unwanted-files.git bare repo.
  4. At the same location I run below command, java -jar bfg-1.13.0.jar --delete-folders "{generated-testfiles-input-full}" dummy-repo-to-test-removal-of-unwanted-files.git/

where generated-testfiles-input-full is a folder in src/test/resources folder which I would like to delete along with its history.

the o/p of above command is,

Using repo : /home/amga/git/project_Name/dummy-branch-to-test-removal-of-unwanted-files.git

Found 1633 objects to protect
Found 4 commit-pointing refs : HEAD, refs/heads/feature/1190/branch1, refs/heads/feature/880/branch2, refs/heads/master

Protected commits
-----------------

These are your protected commits, and so their contents will NOT be altered:

 * commit b2b1eab3 (protected by 'HEAD') - contains 171 dirty files : 
    - project-web/src/test/resources/generated-testfiles-input-full/1-ABC/2019075A.xml (3.2 KB)
    - project-web/src/test/resources/generated-testfiles-input-full/10-XYZ/2019075B.xml (514 B)
    - ...

WARNING: The dirty content above may be removed from other commits, but as
the *protected* commits still use it, it will STILL exist in your repository.

Details of protected dirty content have been recorded here :

/home/amga/git/project_Name/dummy-branch-to-test-removal-of-unwanted-files.git.bfg-report/2019-02-19/11-27-22/protected-dirt/

If you *really* want this content gone, make a manual commit that removes it,
and then run the BFG on a fresh copy of your repo.

Cleaning
--------

Found 1258 commits
Cleaning commits:       100% (1258/1258)
Cleaning commits completed in 334 ms.

Updating 3 Refs
---------------

    Ref                                                  Before     After   
    ------------------------------------------------------------------------
    refs/heads/feature/1190/branch1 | de7175a5 | 7a51367c
    refs/heads/feature/880/branch2  | 0bf7cc52 | a65a3853
    refs/heads/master               | b2b1eab3 | ba92f907

Updating references:    100% (3/3)
...Ref update completed in 22 ms.

Commit Tree-Dirt History
------------------------

    Earliest                                              Latest
    |                                                          |
    ................................................D.DDDmDDDDDD

    D = dirty commits (file tree fixed)
    m = modified commits (commit message or parents changed)
    . = clean commits (no changes to file tree)

                            Before     After   
    -------------------------------------------
    First modified commit | 74657b31 | 4ee2c834
    Last dirty commit     | 0bf7cc52 | a65a3853

In total, 562 object ids were changed. Full details are logged here:

    /home/amga/git/project_Name/dummy-branch-to-test-removal-of-unwanted-files.git.bfg-report/2019-02-19/11-27-22

BFG run is complete! When ready, run: git reflog expire --expire=now --all && git gc --prune=now --aggressive 

Question 1 In the user guide it is said that Examine the repo to make sure your history has been updated, how do I examine repo here for updated history?

  1. then I run cd dummy-branch-to-test-removal-of-unwanted-files.git

  2. then git reflog expire --expire=now --all && git gc --prune=now --aggressive o/p

    Counting objects: 21552, done.
    Delta compression using up to 12 threads.
    Compressing objects: 100% (17743/17743), done.
    Writing objects: 100% (21552/21552), done.
    Total 21552 (delta 13306), reused 7944 (delta 0)

Here the guide says "once you're happy with the updated state of your repo" how do I check the updated state of repo as the branch I'm already on does not delete the expected folder at this stage.

  1. Then I do, git push and the o/p is,
Counting objects: 21552, done.
Delta compression using up to 12 threads.
Compressing objects: 100% (4437/4437), done.
Writing objects: 100% (21552/21552), 292.83 MiB | 8.64 MiB/s, done.
Total 21552 (delta 13306), reused 21552 (delta 13306)
remote: Resolving deltas: 100% (13306/13306), done.
To bitbucket.org:dsintegration/dummy-branch-to-test-removal-of-unwanted-files.git
 + de7175a5...7a51367c feature/1190/branch1 -> feature/1190/branch1 (forced update)
 + 0bf7cc52...a65a3853 feature/880/branch2 -> feature/880/branch2 (forced update)
 + b2b1eab3...ba92f907 master -> master (forced update)

Now when I see in the remote repo it does not delete the folder from master branch but deletes the same from both the feature branches. Can somebody please let me know if I'm going wrong some where.

I'm pretty new for Unix so there might be some basic question in above description. All the testing I'm trying to carry out on some dummy repo once I'm succeed with this will go ahead and apply the same on actual repo.

javabrett commented 5 years ago

You might need the --no-blob-protection option.

amrutaDesai commented 5 years ago

I actually tried to follow following steps,

1.I ran all the commands on master branch separately it self,

  1. Clone the repo with mirror flag and then rerun the bfg for branches

And made it sure that no files/folders exist in any of the branch including master along with its history.

@javabrett thank you for your reply though, I will try to run with this --no-blob-protection flag as well. just for testing.