Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

updating branches using git pull

Tags:

git

git version 1.7.3.5

I have the following branches:

git branch
  image
  master
* video

I did some work at the office. And when I came home I always update on my home's notebook.

However, when I did a git remote show origin I get the following:

  Local refs configured for 'git push':
    image   pushes to image  (up to date)
    master  pushes to master (fast-forwardable)
    video   pushes to video  (local out of date)

So I did a git pull for all of these branches:

git pull origin image
git pull origin master
git pull origin video

When I do a git status on the video and image branch I get:

 nothing to commit (working directory clean)

When I do a git status on the master branch I get:

Your branch is ahead of 'origin/master' by 5 commits.

Which I don't understand the following (fast-forwardable) and (local out of date)?

But in the git status for video it saids its up to date?

Do I need to push my master if it is ahead by 5 commits?

Many thanks for any suggestions

like image 402
ant2009 Avatar asked Jan 30 '11 16:01

ant2009


People also ask

Does git pull update other branches?

git pull is a Git command used to update the local version of a repository from a remote. It is one of the four commands that prompts network interaction by Git. By default, git pull does two things. Updates the remote tracking branches for all other branches.

Does git fetch update current branch?

You can do a git fetch at any time to update your remote-tracking branches under refs/remotes/<remote>/ . This command does not change any of your own local branches under refs/heads , and is safe to do without changing your working copy.

Does git pull pull all branches?

git pull fetches updates for all local branches, which track remote branches, and then merges the current branch.


1 Answers

git remote show origin compares your local repository with the remote:

  • fast-forwardable means you can push your local changes to the remote branch.
  • local out of date means your local branch is behind the remote branch and you should pull from it.

git status compares your local working directory with the current commit of the current branch (aka HEAD). Additionally it compares your local branch with the (local!) tracking copy of the remote branch (origin/master), hence the Your branch is ahead of 'origin/master' by 5 commits.

To solve the divergence between git status (which shows only local data) and git remote show origin (which shows "live" remote data) you should run git remote update origin which will update your local tracking branches. It will update your local origin/master to the state of the remote's master. After that git status should give you something like Your branch is behind 'origin/master' by X commits, and can be fast-forwarded.

like image 168
Koraktor Avatar answered Oct 25 '22 08:10

Koraktor