从git历史记录中删除文件夹:BFG工具删除所有分支

时间:2016-06-06 12:35:01

标签: git bfg-repo-cleaner

我需要从所有分支中删除文件夹缓存。我正在使用BFG工具,但它会移除所有分支但是掌握。这就是我的工作。

步骤1:从本地克隆创建镜像(验证我的本地克隆中有许多分支):

myuser:~/Repositories$ cd test.git
myuser:~/Repositories/test.git$ git --bare init
Initialized empty Git repository in /home/saman/Repositories/test.git/
myuser:~/Repositories/test.git$ cd ../originalrepo
myuser:~/Repositories/originalrepo$ git push -u origin --all
Counting objects: 21103, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8071/8071), done.
Writing objects: 100% (21103/21103), 1.84 GiB | 30.50 MiB/s, done.
Total 21103 (delta 13017), reused 21101 (delta 13015)
To ../test.git
 * [new branch]      idio-additive -> idio-additive
 * [new branch]      idiosyncratic -> idiosyncratic
 * [new branch]      lazy -> lazy
 * [new branch]      list -> list
 * [new branch]      master -> master
 * [new branch]      retake -> retake
 * [new branch]      variance -> variance
Branch idio-additive set up to track remote branch idio-additive from origin.
Branch idiosyncratic set up to track remote branch idiosyncratic from origin.
Branch lazy set up to track remote branch lazy from origin.
Branch list set up to track remote branch list from origin.
Branch master set up to track remote branch master from origin.
Branch retake set up to track remote branch retake from origin.
Branch variance set up to track remote branch variance from origin.

步骤2:在镜像上运行BFG工具

myuser:~/Repositories/originalrepo$ cd ..
myuser:~/Repositories$ java -jar bfg.jar test.git --delete-folders cache

Using repo : /home/saman/Repositories/test.git

Found 435 objects to protect
Found 8 commit-pointing refs : HEAD, refs/heads/idio-additive, refs/heads/idiosyncratic, ...

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

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

 * commit fe37396b (protected by 'HEAD') - contains 284 dirty files : 
    - cache/steadyState_00504943e81e98a199dfe851738dc15bd31eaddba3dd76c81a99d3ff (300.7 KB)
    - cache/steadyState_05fabdf818d4dc580e4ffb4a2769439ab31c20d6f776a52f39f4c175 (300.7 KB)
    - ...

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/saman/Repositories/test.git.bfg-report/2016-06-06/14-21-39/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 668 commits
Cleaning commits:       100% (668/668)
Cleaning commits completed in 564 ms.

Updating 7 Refs
---------------

    Ref                        Before     After   
    ----------------------------------------------
    refs/heads/idio-additive | 2efcf23c | 644b46bf
    refs/heads/idiosyncratic | 581b1c65 | 67ba6839
    refs/heads/lazy          | 065720e5 | 5b7a5327
    refs/heads/list          | 6bf819c0 | 0aa8b0a5
    refs/heads/master        | fe37396b | cea32db5
    refs/heads/retake        | c94a42d8 | 5194e362
    refs/heads/variance      | 3c3c62d8 | f47432bf

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

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

    Earliest                                              Latest
    |                                                          |
    ...........DDmmmmDDDDDDDDDDDDDDDDDmmDDDDDDDDDDDDDDDDDDDDDDDD

    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 | 00d79c52 | b5d26c37
    Last dirty commit     | 2efcf23c | 644b46bf


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

    /home/saman/Repositories/test.git.bfg-report/2016-06-06/14-21-39

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

Has the BFG saved you time?  Support the BFG on BountySource:  


myuser:~/Repositories$ cd test.git
myuser:~/Repositories/test.git$ git reflog expire --expire=now --all && git gc --prune=now --aggressive
Counting objects: 3829, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3812/3812), done.
Writing objects: 100% (3829/3829), done.
Total 3829 (delta 2460), reused 838 (delta 0)

步骤3:从更改后的镜像中克隆,计算分支数

myuser:~/Repositories$ git clone test.git
Cloning into 'test'...
done.
myuser:~/Repositories$ cd test
myuser:~/Repositories/test$ git branch
* master

1 个答案:

答案 0 :(得分:1)

The branches are not linked. #!/bin/bash nc -vz localhost 3306 > /dev/null 2>&1 if [ $? != 0 ]; then /opt/lampp/lampp restart fi shows all the branches, and one can add whatever one wants using git branch -a