Tutorial Example

Fix Git [rejected] master -> master (non-fast-forward) Error – Git Tutorial

When we have pushed our source code to master branch using git, we may get this error: [rejected] master -> master (non-fast-forward) . In this tutorial, we will introduce you how to fix it.

We can push code to master branch using code below:

git push -u origin master

Then we may see:

How to fix this rejected error?

We use steps below.

Step 1: fecth master

Here is the command:

git fetch origin master

Step 2: merge master

git merge origin FETCH_HEAD

Then, we can push our source code.

git commit -m "update source code"
git push -u origin master

Then, we can find this error is fixed.