Search code examples
gitversion-controlbitbucketgit-pullgit-remote

Why I can't pull the new code on the BitBucket repository? Says "Already up-to-date" but I have not all the pushed code


I am not so into GIT and I have the following problem that I can't underestand.

I am using a BitBucket repository where I am working with another person.

I tried to obtain the new code pushed by my coleegue, doing:

git pull

but it says to me:

$ git pull
Already up-to-date.

But on the BitBucket repository (it is in the remote master branch, I can see it into the BitBucket website) there is some code that I have not on my local system.

So I tried to obtain the list of all the remote branches by:

$ git branch -r
  origin/GLIS-Trigger-TAG
  origin/HEAD -> origin/master
  origin/master

So what exactly means? I am pointing to origin/HEAD? What it means? What exactly is origin/HEAD

Have I to switch on the origin/master branch to obtain this code?

What could be the problem and how to fix it?


Solution

  • There are several questions you've asked, and those questions suggest a little additional confusion. So:

    So I tried to obtain the list of all the remote branches by:

    $ git branch -r
      origin/GLIS-Trigger-TAG
      origin/HEAD -> origin/master
      origin/master
    

    So what exactly means? I am pointing to origin/HEAD? What it means? What exactly is origin/HEAD

    What that means is that your local repo has "remote branch references" for a remote named 'origin, and on that remote it sees branches named master and GLIS-Trigger-TAG. The remote's default branch is master (which is what the origin/HEAD entry is saying).

    None of this tells you where you are pointing. Running git branch without the -r would list local branches, and if you're on a local branch then that branch's name will be preceded by a *. You are never "on" a remote branch; if you checkout to a remote branch ref, you will be in detached head state (not on any branch), because local commits don't advance remote branch refs.

    Have I to switch on the origin/master branch to obtain this code?

    No, as I noted trying to do this would put you in detached HEAD state (which is sometimes fine, but is not what you want here.)

    My understanding is that you see the changes on the remote's master branch; so instead you need to switch to the local master branch - because most likely it's set up to track origin/master. (It is by default, so for it to be otherwise you'd have had to deliberately set up a different configuration.)

    git checkout master
    git pull
    

    You can also get updates to all remote refs by

    git fetch
    

    Then you would be able to check the "up-to-date" status of any branch in a number of ways, such as by checking a branch out and running

    git status
    

    or without having to check out branches by

    git diff branch_name origin/branch_name