Home > Back-end >  git force push after rebase still shows "This branch is out-of-date with the base branch"
git force push after rebase still shows "This branch is out-of-date with the base branch"

Time:09-27

I am working on a feature branch but before pushing to github for a PR, I wanted to rebase my branch onto the latest main for which I ran the following commands:

git checkout main
git pull origin main // get the latest version
git checkout feature_branch
git rebase main 
git push -f origin feature_branch

Even though the push was successful, and git log shows my local branch's history contains the latest commits from main however my PR on Github says This branch is out-of-date with the base branch.

I have previously used merge commit via git pull origin main in a local branch and it has always worked but apparently that's not a recommended approach.

How come the remote main branch isn't in-sync with the local despite local containing the latest commits from main?

Edit:

one thing I did notice getting upon running git rebase main was:

First, rewinding head to replay your work on top of it...

It didn't seem like an error and running git log confirmed that the rebase seemed successful.

CodePudding user response:

It's unlikely that GIT will throw the "this branch is out-of-date with the base branch." error if the rebase went well. I would suggest rechecking the logs on your branch using git log --oneline.

CodePudding user response:

One way to check if main got updated on the remote is to just run git fetch, then check the state of origin/main :

git fetch
# view combined history of origin/main and your own branch :
git log --graph --oneline origin/main feature_branch
  • Related