Breaking News
Home / Development / Dev Tools / Your branch is ahead of ‘origin/master’ by 3 commits – Git

Your branch is ahead of ‘origin/master’ by 3 commits – Git

Error

On trying to update files (pull) from the master branch into your local in GIT, the following error shows up:

# Your branch is ahead of ‘origin/master’ by 3 commits.

Solution

Check your working directory with git status command.

* If you are not sure about GIT’s working or don’t know why you ended you with this out of sync it is always better to make a backup copy of the working directory just in case something gets wrong. GIT does have ways to recover lost commits but it can be bit involved process, so having a local backup will certainly be very handy.

macbook:RoHD mvohra$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 3 commits.
#   (use “git push” to publish your local commits)
#
nothing to commit, working directory clean
macbook:RoHD mvohra$

Basically you are working on a branch that has X no. of commits 3 in this case compared to origin one. If we want to ignore those commits and be in sync with the latest greatest from the master we can use the git fetch command as follows:

macbook:RocksHD mvohra$ git fetch origin
From https://github.com/aramamssoo/RoHD
b3163e6..24e2976  master     -> origin/master

Once again check the status , that error will not show up anymore.<!>macbook:RocksHD mvohra$ git status
# On branch master
nothing to commit, working directory clean[pb_builder]

Advertisment ad adsense adlogger