How can I find the location of origin/master in git, and how do I change it?

I came to this question looking for an explanation about what the message “your branch is ahead by…” means, in the general scheme of git. There was no answer to that here, but since this question currently shows up at the top of Google when you search for the phrase “Your branch is ahead of ‘origin/master'”, and I have since figured out what the message really means, I thought I’d post the info here.

So, being a git newbie, I can see that the answer I needed was a distinctly newbie answer. Specifically, what the “your branch is ahead by…” phrase means is that there are files you’ve added and committed to your local repository, but have never pushed to the origin. The intent of this message is further obfuscated by the fact that “git diff”, at least for me, showed no differences. It wasn’t until I ran “git diff origin/master” that I was told that there were differences between my local repository, and the remote master.

So, to be clear:


“your branch is ahead by…” => You need to push to the remote master. Run “git diff origin/master” to see what the differences are between your local repository and the remote master repository.


Hope this helps other newbies.

(Also, I recognize that there are configuration subtleties that may partially invalidate this solution, such as the fact that the master may not actually be “remote”, and that “origin” is a reconfigurable name used by convention, etc. But newbies do not care about that sort of thing. We want simple, straightforward answers. We can read about the subtleties later, once we’ve solved the pressing problem.)

Earl

Leave a Comment