首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从git历史记录中删除文件夹: BFG工具删除所有分支

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

Stack Overflow用户
提问于 2016-06-06 20:35:01
回答 1查看 1.3K关注 0票数 2

我需要从所有分支中删除文件夹缓存。我使用的是BFG工具,但是它会删除除master之外的所有分支。这是我要做的。

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

代码语言:javascript
运行
复制
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工具

代码语言:javascript
运行
复制
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:从修改后的镜像克隆,计算分支数量

代码语言:javascript
运行
复制
myuser:~/Repositories$ git clone test.git
Cloning into 'test'...
done.
myuser:~/Repositories$ cd test
myuser:~/Repositories/test$ git branch
* master
EN

回答 1

Stack Overflow用户

发布于 2016-06-06 22:16:47

分支未链接。git branch -a显示所有分支,用户可以使用git checkout -b branchname remote/branchname添加任何内容

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37657641

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档