开发者

How to remove unwanted extra root commit in git repository?

I recently converted a subversion repo, which had been converted from cvs before that and I've ended up with the following structure (simplified for clarity) at the bottom of the tree:

* master开发者_如何学运维
|
...
|
|
* G 
|\
| * F
| * E
| * D
| * C Initial commit.
|
|
* A New repository initialized by cvs2svn.

The line from G-A contained unwanted commits which I've removed successfully with "git filter-branch". I'd like to be able to remove that line entirely, including the initial empty root commit at A and just have a single line going back to C.

So I'd like to remove A as a parent of G and allow it to be gc'd, but I'm not sure if that's possible.


Use git filter-branch with a --parent-filter on G:

$ git filter-branch --parent-filter \
    'test $GIT_COMMIT = G && echo "-p F" || cat' HEAD

where you replace G and F with the actual SHA-1 values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜