prabal dutta prabal dutta - 1 month ago 13
Git Question

Trying to push the changes on GitHub, but I am getting an error

Consider:

! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/dvtta/pinter.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Answer

Problem reason

You are trying to push to the remote repository without already being in sync with it. So either pull first and then push to it....

do a git pull

and then do git push

The hard way to resolve this (Don't do it until you have to)

git push -f

The above command will however strip off the things that you are not in sync of. In other words all those commits that you don't have will be removed from the repo by this command.

So DON'T USE IT until you have to.

Comments