Git Lesson : branch is ahead by x commits

  If Git suddenly popup a warning, “branch is ahead by x commits”.

You can do the following

Switch to the branch, e.g it’s the Master branch

git checkout master

Then, use Git Fetch to update the local copy of a remote branch

git fetch

Git fetch is similar to pull, except it won’t do any merging