Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k 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 (50.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.

Browse Categories

...