Daniele B
Daniele B

Reputation: 20412

GIT: cannot push to origin/master

enter image description here

This is my situation.

I had pushed version 2.1.6, but it was buggy, so I reverted my filesystem to the 2.1.5 and I then made some changes which I tagged 2.1.7.

Now I cannot push 2.1.7 to origin/master as it says:
Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g.hint: 'git pull ...') before pushing again.

I am very lost now. What should I do, if I just want to discard 2.1.6, and set the origin/master to 2.1.7?

Upvotes: 1

Views: 386

Answers (2)

John Bupit
John Bupit

Reputation: 10618

This is your current situation:

... ---A------------E master, 2.1.7
       \---B---C---D origin/master

Using git pull --rebase would help you reach this:

... ---A---B---C---D---E master, 2.1.7, origin/master

Finally, git push your changes:

git checkout master
git pull --rebase
git push

Or simply using git push --force would help you achieve this:

... ---A------------E master, 2.1.7
       \---B---C---D origin/master

git checkout master
git push --force

... ---A------------E master, 2.1.7, origin/master

Upvotes: 3

Josip Ivic
Josip Ivic

Reputation: 3709

Have you updated your code before pushing ?

use git pull origin master before you push anything.

I assume that you are using origin as a name for your remote. Origin is a remote. You can use git remote --verbose to see all the remote configured under your git folder.

You can use git reset --hard -> Resets the index and working tree. Any changes to tracked files in the working tree since are discarded.

Upvotes: 0

Related Questions