Remove spurious commit parent pointer

前端 未结 4 2165
暖寄归人
暖寄归人 2020-12-06 01:24

I imported a Bazaar repository into Git (using git bzr), but the resulting repository contains a spurious commit parent link:

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 01:49

    The easiest way to do this (in git >= 1.6.5) is to use:

    git replace --edit 
    

    and remove/add/change the Parent: lines.

    Once you are happy the change is right, you can rewrite the commits to make the change permanent:

    git filter-branch --tag-name-filter cat -- --all
    

    In some cases it'll be noticeably quicker to only rewrite the commits involved and not the full history (thanks to Michael for mentioning this in the comments); e.g. to rewrite only commits on the current branch:

    git filter-branch --tag-name-filter cat -- ..head
    

    If you're not sure, use --all, otherwise you risk ending up with other branches/tags still referencing the temporary replacement object.

提交回复
热议问题