6

Our company's workflow is to clone master branch into a _Test branch as we work on new features and we continually push/share this _Test branch until a set of features are complete and approved by client, then we merge to master branch and build and publish our sites. Then rinse and repeat.

The problem I'm having is git status isn't showing the correct ahead/behind (or more likely, I may not understand what it is supposed to show) while working on the _Test branch. If I do the following steps:

  1. git checkout _Test
  2. git pull --rebase origin _Test # get latest code
  3. edit some files
  4. get commit -am "Test commit"
  5. git status

After step four, the git output is

[_Test d6fa824] Test commit
1 file changed, 1 insertion(+), 1 deletion(-)

Then after step five, the git output is

# On branch _Test
nothing to commit, working directory clean

Shouldn't it say?

Your branch is ahead of 'origin/_Test' by 1 commit.

If I look at qgit or gitk they show origin/_Test and remotes/origin/_Test respectively (correctly) 1 commit behind the last test commit. I'm running msysgit and git version outputs:

git version 1.8.1.mysysgit.1

So I'm confused why the output from git commit doesn't state that I'm ahead of origin/_Test (when obviously I am since I just committed) and why git status doesn't state same information.

Let me know if I need to provide any more info.

Terry
  • 2,148
  • 2
  • 32
  • 53
  • duplicate of http://stackoverflow.com/questions/5341077/git-doesnt-show-how-many-commits-ahead-of-origin-i-am-and-i-want-it-to – stevemao Jan 20 '15 at 02:43

1 Answers1

5

I resolved this problem.

You basically need to set up git tracking using

git branch --set-upstream *branch_name*

Read my full explanation here

umläute
  • 28,885
  • 9
  • 68
  • 122
gray
  • 798
  • 18
  • 31
  • Hmm, I resolved by not doing a git pull specific to _Test, I just did git pull as a 'global' command, expecting/hoping it would just update all branches 'as needed'. It has seemed to solve my problem, but maybe your way is the proper way to go? I googled around and saw similar comments about my problem and people were suggesting just doing a full pull?? – Terry Sep 17 '13 at 16:28
  • I'm fairly new to using git, so I wouldn't say the way I did it was the proper way..thanks for stating the way you did it though, it looks a lot quicker than how I did it – gray Sep 17 '13 at 18:46
  • 3
    git recommends using `git branch --set-upstream-to ...` now – kingPuppy Dec 31 '16 at 00:09