开发者

How to see a branch created in master

I create a branch in my master r开发者_开发百科epository (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://richard@192.168.1.2/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'?


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.


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜