There isn't anything to compare. Nothing to compare, branches are entirely different commit histories

后端 未结 18 907
北恋
北恋 2020-12-12 22:54

I have a CMS theme installed on my machine. I\'m tracking changes to it via git and decided to back it up on GitHub so I could share those changes.

The theme as prov

18条回答
  •  被撕碎了的回忆
    2020-12-12 23:03

    This looks like undesirable behavior on github's part, but it's fairly easy to fix. What you want to do is to rebase your branch on a reasonable (any reasonable) commit in the existing history. What you can do is to fetch the github repo and find which tree in its history is most similar to the one you started with. Start this way:

    git remote add github u://r/l
    git fetch github
    
    myroot=`git rev-list master --max-parents=0`
    root_tree=`git rev-parse $myroot^{tree}`
    
    github_base=`git log --pretty=%H\ %T github/master | sed -n "s/$root_tree//p"`
    

    With any luck, that will find you a commit in the github history that has the exact tree you started with. Assuming it does,

    git rebase --onto $github_base $myroot master 
    

    and you're done.


    If that doesn't find a matching tree, you get to find a nearest approximation. Here's one way to get a rough estimate of the differences:

    git log --pretty='echo %H $(git diff-tree -p -b -U0 '$myroot:' %T|wc -l)' github/master \
    | sh
    

    which will count the lines in a minimized diff between the tree of each commit in the github/master history and your root tree. It seems reasonable to hope for a nice small difference, you could eyeball the actual diffs on it before calling that the github_base commit and doing the rebase above.


提交回复
热议问题