What does git filter-branch with no arguments do?

前端 未结 3 1330
无人及你
无人及你 2021-01-13 11:41

What does git filter-branch with no arguments do?

I ran this on my repo accidentally hitting enter prematurely.

相关标签:
3条回答
  • 2021-01-13 12:00

    Filter-branch inspects and does any needed rewriting of the commits output by a git rev-list fed the arguments it passes along. With no arguments to pass along, rev-list uses HEAD, your current checkout.

    Along with any modifications you specify on the command line, filter-branch also bakes in local overrides from .git/info/grafts and git replace.

    So to orphan the current checkout you can git rev-parse @ >.git/info/grafts; git filter-branch

    0 讨论(0)
  • 2021-01-13 12:05

    Nothing. It seemed to calculate the hashes and found no change.

    0 讨论(0)
  • 2021-01-13 12:15

    This is used for graft, as mentioned in git filter-branch:

    To set a commit (which typically is at the tip of another history) to be the parent of the current initial commit, in order to paste the other history behind the current history:

    git filter-branch --parent-filter 'sed "s/^\$/-p <graft-id>/"' HEAD
    

    That will be faster with git 2.6.4 or git 2.7 (Dec. 2015)

    See commit 348d4f2 (06 Nov 2015) by Jeff King (peff).
    (Merged by Junio C Hamano -- gitster -- in commit 2e5adec, 04 Dec 2015)

    filter-branch: skip index read/write when possible

    If the user specifies an index filter but not a tree filter, filter-branch cleverly avoids checking out the tree entirely.
    But we don't do the next level of optimization: if you have no index or tree filter, we do not need to read the index at all.

    This can greatly speed up cases where we are only changing the commit objects (e.g., cementing a graft into place).
    Here are numbers from the newly-added perf test:

    Test                  HEAD^              HEAD
    ---------------------------------------------------------------
    7000.2: noop filter   13.81(4.95+0.83)   5.43(0.42+0.43) -60.7%
    
    0 讨论(0)
提交回复
热议问题