Reputation: 59
when i use the command
git push origin master
The following error is displayed:
Username for 'https://github.com': amithld
To https://github.com/amithld/datasciencecoursera.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/amithld/datasciencecoursera.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.
Even I tried to pull the remote repo, it showed error! Note: I have already made the remote repo and initialized it with the readme file.
Please, suggest solutions.
Thanks
Upvotes: 0
Views: 4908
Reputation: 522762
Read the error message closely:
Updates were rejected because the tip of your current branch is behind its remote counterpart
This means that new commits were made to the remote branch since when you last synched, and now Git does not know how to apply the work you have done since then. You can resolve this by doing:
git pull origin master # merge the remote into your local branch
or
git pull --rebase origin master # rebase your local branch on the remote
After this, the following should ideally work:
git push origin master
Upvotes: 4