failed to push some refs to 'https://github.com/myname/myrepo'

天涯浪子 提交于 2019-12-12 08:59:54

问题


question on magit / push

I'm starting using magit, with very little experience in git.

I've gone trough the magit manual with success for :

adding
ignoring
staging
commiting locally

Then, I try to push on github.com/myname. For that, I use 'P P', entering then my username and password.

If fails with

To https://github.com/myname/myrepo ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/myname/myrepo'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push –help' for details.

git exited abnormally with code 1.

I thought I would solve it as mentionned here with git config --global push.default current But it doesn't help.

I've had a lok at Geting an error pushing to github - Updates were rejected because a pushed branch tip is behind its remote but did'nt got it to work

Any idea ?


回答1:


You have to either pull changes first or push -f the changes.




回答2:


I am always a big fan of using git pull --rebase and then git push origin master since a lot of places where you can work will not allow a push -f.

git pull --rebase 
git push origin master

The rebase will apply your changes after those already to the remote (online website). This video literally goes over your exact issue and solves it using git pull --rebase https://youtu.be/IhkvMPE9Jxs?t=10m36s



来源:https://stackoverflow.com/questions/14801972/failed-to-push-some-refs-to-https-github-com-myname-myrepo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!