Search code examples
gitpull-requestgit-pull

Git pull gives "Already up to date" but remote branch shows confilcts


So I've just recently started using more of git functionality and I'm a bit lost.

  • I cloned the repo from master branch.

  • Did some coding.

  • I git checkeout -b newbranch then git commit and git push origin newbranch

  • I did pull request in bitbucket but it was pointing to master branch and I was told to point it to develop branch so I did. Then I got: enter image description here

  • So in my terminal i did git checkout develop but when I tried to git pull I got Already up to date message. So if develop branch is different than newbranch and it's causing conflicts why I can't pull it? What don't I understand here?

I need to get the code from develop branch, resolve conflicts and than push it again and do pull request again.


Solution

  • The conflicts you need to solve are between develop and newbranch.

    The two main ways to fix this issue from your local repo are :

    1. rebase newbranch on top of develop
    # from branch 'newbranch' :
    git checkout newbranch
    
    # rebase on top of 'develop' :
    git rebase develop
    
    # if you actually need to edit or drop commits along the way, you may use
    # an interactive rebase :
    git rebase -i develop
    
    1. merge develop into newbranch
    # from branch 'newbranch' :
    git checkout newbranch
    
    # merge 'develop' :
    git merge develop
    

    Choose whichever way is adapted to your workflow.

    You will need to fix conflicts to complete either of these actions -- your remote says that there are some.


    Once you are satisfied with your updated newbranch on your local repo, push it to your remote :

    git push origin newbranch
    
    # if you ran rebase, you will need to force push your branch :
    git push --force-with-lease origin newbranch