Debug School

rakesh kumar
rakesh kumar

Posted on

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

git-updates-were-rejected-because-the-tip-of-your-current-branch-is-behind

ERROR:git: "Updates were rejected because the tip of your current branch is behind.." but how to see differences?

To github.com:holidaylandmark/holiday.git
 ! [rejected]          master -> master (non-fast-forward)
error: failed to push some refs to 'github.com:holidaylandmark/holiday.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.
Enter fullscreen mode Exit fullscreen mode

Image description

Solution

git push -f, a force push to update the remote (origin) branch.
Enter fullscreen mode Exit fullscreen mode

0

I found this command works correctly:

git push -u origin main -f

You just need to add a -f flag to force the push.
Enter fullscreen mode Exit fullscreen mode

1. Take a backup if you're working on feature branch and switch to master/develop branch by doing git checkout develop/master
2. Do git pull
3. You will get changes and merge conflicts occur when you have made changes in the same file which has not been rebased from develop/master
4. Resolve the conflicts if it occurs and do git push,this should work
Enter fullscreen mode Exit fullscreen mode

Top comments (0)