What does git filter-branch with no arguments do?

前端 未结 3 1329
无人及你
无人及你 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: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 /"' 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%
    

提交回复
热议问题