tags:

views:

39

answers:

4

Hi,

I create a branch in my master repository (192.168.1.2). And in my other computer, I did '$ git pull --rebase ', I see

Unpacking objects: 100% (16/16), done.
From git+ssh://[email protected]/media/LINUXDATA/mozilla-1.9.1
62d004e..b291703  master     -> origin/master
* [new branch]      improv -> origin/improv

But when I do a 'git branch' in my local repository, I see only 1 branch and I did '$ git checkout improv '

$ git branch                                              
* master
$ git checkout improv                                 
error: pathspec 'improv' did not match any file(s) known to git.
Did you forget to 'git add'?
+1  A: 

Try $ git fetch origin first. Other than that, your git version might not be as fresh so you should do $ git checkout --track -b improv origin/improv

Eimantas
+1 for using less words than me. >_>
Blair Holloway
+1  A: 

To checkout and create the branch together from master, you need to do this:

git checkout origin/master -b improv

To list the branches at remote repository, you should use

git branch -r

or just use

git branch -a

to list all branches including both remote and local ones.

sza
If your current branch is already `master`, you can shorten the checkout command to just `git checkout -b improv`.
Blair Holloway
A: 

The new branch, improv, exists on the origin (your master repository) but is not pulled when issuing a $git pull command This is by design. On your local machine you probably want to do something like $git checkout --track origin/improv to pull the brach and add it to your local track list.

labratmatt
+2  A: 

In your case, you have two problems:

  • your local working copy isn't up-to-date, and
  • locally, you don't have an improv branch that tracks the copy on the server (similar to how master tracks origin/master).

First, you need to run:

$ git fetch

Which will update your remote refs (locally, a ref to origin/improv will appear). Then, run:

$ git checkout -b improv --track origin/improv

To create a new local branch, improv, that tracks the branch on the server, origin/improv. (This branch will be up-to-date on your local machine.) Your local improv branch will then automatically merge changes from improv on the server (and hence, your other machine) when you run git pull.

Blair Holloway