Khalid Riaz
Khalid Riaz

Reputation: 43

failed to push some refs -tip of your current branch is behind its remote counterpart

I tried to push a file ("HelloWorld.md") on my local repository to remote repository on hithub. I got the following error message. How do I remove this error?

error: failed to push some refs to 'https://github.com/kriaz100/DataScienceCours era.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Upvotes: 4

Views: 2439

Answers (3)

quangdang
quangdang

Reputation: 374

You can add -f parameter in git command

git push -f origin 'branch_name'
Example: 
git push -f origin main

Upvotes: 0

v-andrew
v-andrew

Reputation: 24221

Some changes were done remotely. For example you could change your HelloWorld.md using Github web UI

You have to merge local branch with origin recursively

Try

git pull origin your-branch-name -v

It will merge origin into your local branch.

Upvotes: 3

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

Upvotes: 3

Related Questions