Remove spurious commit parent pointer

前端 未结 4 2160
暖寄归人
暖寄归人 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:45

    This will correct the parents without changing anything else (eg. committer dates):

    git filter-branch --tag-name-filter cat --parent-filter 'test $GIT_COMMIT = [sha of 1.02-6] && echo "-p [sha of 1.02-3]" || cat' -- 1.02-1..master

    You will have to replace the bracketed text with the appropriate commit IDs. If you have more downstream branches that need to be rewritten, change 1.02-1..master to --all and be prepared to wait.

    Of course, don't use this or any other solution if others have branched from any commits after the ones you want to edit. They will hate you.

提交回复
热议问题