Git doesn’t show how many commits ahead of origin I am, and I want it to

git

There are plenty of questions here about Git saying people are ahead of a remote branch by X commits, and they want it to stop.

I have the opposite problem. I want Git to tell me how many commits ahead I am, but it doesn't.

When I created my remote bare repository first, then cloned from it, this worked. In my current case I created the local repository first, then cloned it (bare) to the remote.

This set up my local repository as the remote for the bare repository. But I removed that, and manually added the remote repository reference to my local. Pushing works fine. But I don't see the "You are ahead by X commits" message. How can I get it?

Best Answer

git branch --set-upstream local origin/remote

local and remote are the names of your local resp. remote branches.

In Git version 1.8 and later, it's even easier. Make sure you're on the local branch, and then:

git branch --set-upstream-to origin/remote