0 votes
1 view
in Devops and Agile by (29.9k points)

I'm new to GitHub. Today I met some issues when I was trying to push my code to GitHub.

Pushing to [email protected]:519ebayproject/519ebayproject.git

To [email protected]:519ebayproject/519ebayproject.git

 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to '[email protected]:519ebayproject/519ebayproject.git'

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.

I have not pushed anything in the repository yet, so why do I need to pull something?

1 Answer

0 votes
by (51.2k points)

If you don’t wish to merge a remote branch into your local branch then you can do a force push using:

git push -f origin <branch>

Generally, the origin will be the name of your remote repo.

Note: Usually, the command refuses to update a remote repo that is not an ancestor of the local ref used to overwrite it. This flag disables the check.

This can cause the remote repository to lose commits; use it with care. So use this command with care so that it will push the branches to github.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !