Cannot push to GitHub - keeps saying need merge

后端 未结 30 2097
天命终不由人
天命终不由人 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:56

    If by any chance git pull prints Already up-to-date then you might want to check the global git push.default param (In ~/.gitconfig). Set it to simple if it was in matching. The below answer explains why:

    Git - What is the difference between push.default "matching" and "simple"

    Also, it is worth checking if your local branch is out of date using git remote show origin and do a pull if needed

    0 讨论(0)
  • 2020-11-22 00:58

    Sometimes we forgot the pulling and did lots of works in the local environment.

    If someone want to push without pull,

    git push --force
    

    is working. This is not recommended when working with other people, but when your work is a simple thing or a personal toy project, it will be a quick solution.

    0 讨论(0)
  • 2020-11-22 01:00

    use git pull https://github.com/username/repository It's because the Github and remote repositories aren't in sync. If you pull the repo and then Push everything will be in sync and error will go away.

    `

    0 讨论(0)
  • 2020-11-22 01:01

    This normally happens when you git commit and try to git push changes before git pulling on that branch x where someone else has already made changes.

    The normal flow would be as below,

    STEP 1: git stash your local uncommitted changes on that branch.

    STEP 2: git pull origin branch_name -v to pull and merge to locally committed changes on that branch (give this merge some message, and fix conflicts if any.)

    STEP 3: git stash pop the stashed changes (Then you can make commits on popped files if you want or push already committed changes (STEP4) first and make new commit to files later.)

    STEP 4: git push origin branch_name -v the merged changes.

    Replace branch_name with master (for master branch).

    0 讨论(0)
  • I had the same problem , what I did was I first pushed it by force by using this

    git push --force
    

    I did this after I commited the files and was getting an error as you got.It did commit all the files and it pushed them. Then the next time I was pushing to the github .I did what it asked me to and it was alright then. Hope this works for you too :)

    0 讨论(0)
  • 2020-11-22 01:01

    git pull prints Already up-to-date

    solution:

    you might be created a repository/project in remote(server) and added some file there, Then again created a Folder in your local and initialised git git init - this is the mistake, you should not create git init in local, instead clone the project to your local using git clone

    then pull

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