git status FAQ: When I issue the git status
command, I see the following “Your branch is ahead or origin/master ...” message:
# On branch master # Your branch is ahead of 'origin/master' by 5 commits. # nothing to commit (working directory clean)
What does this message mean? Read on ...
git status message: Your branch is ahead of ‘origin/master’ by X commits
These git “Your branch is ahead of origin/master” and “nothing to commit” messages can be misleading, especially to new git users (like myself). The thing to know here is that your branch isn’t ahead of the the master — your branch is the master.
What the git message is saying is that you’re ahead of “origin/master,” which is usually the branch on your remote git origin server. (You most likely did a git clone
to get your git repo from the origin server.) This message is telling you that you’ve made some changes locally, and you’re now ahead of the origin server. In a sense, this message is a reminder that you need to push your changes back to the origin server.
If you’re working on a simple project (like I am) you can push your changes back to the origin server with this command:
git push origin master
Git commit is not “cvs commit” or “svn commit”
Frankly, this is something I really struggled with regarding Git. When I first started with Git I was used to “cvs commit” or “svn commit” committing my changes back to the server, but with Git this is a multi-step step process, as shown here:
# make your changes $ git add . $ git commit -m 'your message' $ git push origin master
If you forget that last step — which I always used to do — you’ll see the “Your branch is ahead of origin/master by X commits” git status message, along with the “nothing to commit” message (again, reminding you to do a git push
).