'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.
Solution 1:[1]
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.
Solution 2:[2]
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
Solution 3:[3]
You can add -f parameter in git command
git push -f origin 'branch_name'
Example:
git push -f origin main
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Michael James Kali Galarnyk |
| Solution 3 | quangdang |
