Tag Archives: Updates were rejected because the tip of your current branch is behind

[Solved] Updates were rejected because the tip of your current branch is behind

Problem Description.

Updates were rejected because the tip of your current branch is behind

Scenario.

Create a project on github or coding, then git init locally

and then no git pull -f –all

The readme file in the github version conflicts with the local version, and the reason for the conflict is given below.

[master][~/Downloads/ios] git push -u origin master

Username for ‘https://github.com’: shiren1118
Password for ‘https://[email protected]’:
To https://github.com/shiren1118/iOS_code_agile.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to ‘https://github.com/shiren1118/iOS_code_agile.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.

 

Workaround:

Check the box to force overwrite existing branches (changes may be lost), then click upload, and the upload succeeds.

[master][~/Downloads/ios] git push -u origin master -f

Translated with www.DeepL.com/Translator (free version)

 

Git push Updates were rejected because the tip of your current branch is behind

git push Error Updates were rejected because the tip of your current branch is behind

DannideMacBook-Pro:connect-cas2-client danni$ git push origin master
To https://gitee.com/danni3/connect-cas2-client.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/danni3/connect-cas2-client.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: git pull origin master

DannideMacBook-Pro:connect-cas2-client danni$ git pull origin master
From https://gitee.com/danni3/connect-cas2-client
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

git pull origin master—allow-unrelated-histories