Cannot push to GitHub - keeps saying need merge

后端 未结 30 2909
天命终不由人
天命终不由人 2020-11-22 00:09

I\'m new to GitHub. Today I met some issue when I was trying to push my code to GitHub.

Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@gi         


        
30条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 00:41

    I had a similar issue and it turned out that my workflow for keeping my branch up to date was at fault. I was doing the following:

    In my local 'master'

    git fetch upstream
    git merge upstream/master --ff-only
    

    then back in my local branch

    git rebase master
    

    This worked well for a previous git flow but not with github. The git rebase was the problem here causing issues with syncing (and I'll admit that's something I've had to accept without fully understanding) and unfortunately put me in a position where git push -f became probably the easiest option. Not good.

    My new flow is to update the branch directly using git merge as follows:

    In my local branch

    git fetch upstream
    git merge upstream/master
    

    No fast forward, as I will have made changes of course in the local branch.

    As you can probably tell, I'm no git expert but I'm reliably informed that this workflow will probably avoid the specific problems that I had.

提交回复
热议问题