git - duplicate parent
I seem to have managed to have a commit with two duplicate parents using eGit (Eclipse's git client, powered by JGit).
The 2nd parent causes that green 'branch to nowhere' that we can't get rid of.
I've been googling ways to perform some surgery on the commit to remove the extra parent, but to no avail.
Running cat-file I get:
$ git cat-file -p 26dc6a5b44373f766d81513ab84c5eecaf876736
tree 527df208ee66f52bc414948b1de0fa6607cfb81c
parent bc9d55d0451b325b4ad5a758be8b30c1418b3af9
parent bc9d55d0451b325b4ad5a758be8b30c1418b3af9
author Roy Truelove <开发者_JAVA技巧;roy.truelove@xxxx.com> 1316457571 -0400
committer Roy Truelove <roy.truelove@xxxx.com> 1316457571 -0400
I'm sharing this repo and this problem has already been pushed, which I'm sure will contribute to the complexity of the solution..
Thanks git hackers, Roy
PS - I do have command line access to this repository (cygwin) if I need to perform a function not available through eGit
You can use git filter-branch
to rewrite the history; the duplicate parent will automatically be corrected.
In order to remove the duplicate parent from the commit you can do this:
git replace <sha1> $(git cat-file commit <sha1> | uniq | git hash-object -t commit -w --stdin)
The commit with the duplicate parent has been temporarily replaced with a new commit that does not contain the duplicate parent. You can check if the gitk display problem has gone away now.
In order to permanently replace the commit you can use git filter-branch. Note that at that point you will have rewritten history. All developers working on this project must be made aware of this, so that they can also rebase/reset their local work/copies to the new history.
精彩评论