I am working on the team project on GitHub. I am facing the error :
Updates were rejected because a pushed branch tip is behind its remote counterpart. Check out this branch and integrate the remote changes (e.g. 'git pull ...') before pushing again.
Here is the situation : I pulled the main branch code from GitHub and started working on it locally and later I pushed the changes to temp_branch using this command.
git push origin main:temp_branch
Meanwhile, some other changes has been added to the main branch on GitHub (my changes on temp_branch
are not yet merged) and I was told to make some additional changes.
Now, I have made the changes and trying to push to the same temp_branch using these two commands
git pull --rebase origin main
git push origin main:temp_branch
On doing this, I am getting the mentioned error. I was referring to this link but it does not exactly answers my problem and it suggests to use -f
force push to override the content which I don't want to.
Updates were rejected because the tip of your current branch is behind its remote counterpart
I want to know what exactly is happening here and how do I resolve this?