Search code examples
gitintellij-ideagit-branchgit-pullgit-checkout

Why "git pull" is updated files when implemented immediately after checking out a remote branch?


I use IntellijIDEA,

  1. At the branches view( right bottom corner) I select a brunch from remote branches which I have never checked out before ( I didn't even knew it's name before read at my Jira task )
  2. Clicked on it
  3. Checkout As...
  4. Left the original name ( the same as remote name)
  5. OK

I I wish I got an up to date branch ( isn't it reasonably?) but when I immediately select Git -> pull, I got 588 files updated in 627 commits at this branch?

Please explain what is the logic? Isn't it reasonably to expect to get an up to date branch when checkout and expect pull will say "everything is up to date" ?


Solution

  • The problem lies to the fact that those branches are lastly updated the last time you git pull -all.

    For example, If you clone a project, those branches come with the latest commits (up to date). But if you don't git pull --all for some time then those branches aren't going to be updated. In that case your branches do not contain the last updates and so you have to git pull -all in order to update them.

    In sum up, the branches are lastly updated from the time you cloned the project or the last time you git pull -all, but they are not automatically updated.

    If there are new branches added to the remote then you have to fetch them first with git fetch --all.