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

后端 未结 18 802
北恋
北恋 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:10

    I had an issue where I was pushing to my remote repo from a local repo that didn't match up with history of remote. This is what worked for me.

    I cloned my repo locally so I knew I was working with fresh copy of repo:

    git clone Your_REPO_URL_HERE.git
    

    Switch to the branch you are trying to get into the remote:

    git checkout Your_BRANCH_NAME_HERE
    

    Add the remote of the original:

    git remote add upstream Your_REMOTE_REPO_URL_HERE.git
    

    Do a git fetch and git pull:

    git fetch --all
    
    git pull upstream Your_BRANCH_NAME_HERE
    

    If you have merge conflicts, resolve them with

    git mergetool kdiff3 
    

    or other merge tool of your choice.

    Once conflicts are resolved and saved. Commit and push changes.

    Now go to the gitub.com repo of the original and attempt to create a pull request. You should have option to create pull request and not see the "Nothing to compare, branches are entirely different commit histories" Note: You may need to choose compare across forks for your pull request.

    0 讨论(0)
  • 2020-12-12 23:10

    I had mine solved by overriding the branch:

    My case: I wanted to override whatever code is in the develop with version_2.

    1. delete the local copy of conflicting branch:
    git checkout version_2
    git branch -D develop
    
    1. checkout a fresh branch from the version_2 and force push to git:
    git checkout -b `develop`
    git push origin `develop`
    

    I didn't need to rebase. But in my case, I didn't need to take code from my old code.

    0 讨论(0)
  • 2020-12-12 23:13

    I found that none of the answers provided actually worked for me; what actually worked for me is to do:

    git push --set-upstream origin *BRANCHNAME*
    

    After creating a new branch, then it gets tracked properly. (I have Git 2.7.4)

    0 讨论(0)
  • 2020-12-12 23:13

    I got this error message, because I was migrating an application from SVN to GitHub and it's not enough to invoke a git init in the location of the source code checked out from SVN, but you need to invoke a git svn clone in order to have all the commit history. This way the two source codes on GitHub will have a mutual history and I was able to open pull requests.

    0 讨论(0)
  • 2020-12-12 23:13

    I wanted to copy commit history of "master" branch & overwrite the commit history of "main" branch .
    The steps are:-

    1. git checkout master
    2. git branch main master -f
    3. git checkout main
    4. git push

    To delete master branch:-

    a. Locally:-

    1. git checkout main
    2. git branch -d master

    b. Globally:-

    1. git push origin --delete master

    Do Upvote it!

    0 讨论(0)
  • 2020-12-12 23:14

    The Short Answer

    It looks like GitHub won't let you compare the branches because they don't actually share any of the same history at all, even though they may share much of the same files and code.

    Here is a screenshot of the temporary fork I made of your repo, where I tried to compare master with the upstreambranch, like you described. Notice the error message:

    Error message screenshot

    It says:

    There isn't anything to compare.

    master and upstreambranch are entirely different commit histories.

    The Long Answer

    You probably downloaded the original source and added it to a completely new repo instead of cloning the original repo, right? Doing that will make it so that the history of your repo will be completely different from the history of the original repo, since your new repo won't have any of the same commits with the same sha IDs.

    You can see that by doing a reverse log of your master branch and the upstreambranch:

    # Your first commit, see commit sha
    git log --reverse master
    commit c548d7b1b16b0350d7fbdb3ff1cfedcb38051397 # <== HERE
    Author: Padraic Stack <padraic.stack@nuim.ie>
    Date:   Wed Apr 2 15:11:28 2014 +0100
    
        First commit of everything
    
    # First commit sha of the original repo
    git log --reverse upstreambranch
    commit 105a12817234033c45b4dc7522ff3103f473a862 # <== THERE
    Author: Jeremy Boggs <jeremy@clioweb.org>
    Date:   Mon Feb 22 16:00:53 2010 +0000
    
        Creates repo directories for the Seasons theme.
    

    Solutions

    If you redo your commits on top of the original history, you should then be able to compare the branches. There are several different ways that you can redo your commits, including

    git rebase --onto
    

    and

    git cherry-pick
    

    You also can redo each commit manually, if you have to.

    0 讨论(0)
提交回复
热议问题