Question

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 ?

Était-ce utile?

La solution

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

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top