.
.
.
.
.
在本地工程中添加Git,并将其与远程的空库关联起来,只需如下几步。
1. 创建空库
$ git init Initialized empty Git repository in D:/workspace/shop/.git/
2. 添加远程仓库
$ git remote add origin ssh://user@192.168.1.2:29418/prj/shop
3. 获取仓库中的分支
$ git fetch remote: Counting objects: 2, done remote: Finding sources: 100% (2/2) remote: Total 2 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (2/2), done. From ssh://192.168.1.2:29418/prj/shop * [new branch] master -> origin/master $ git branch -a remotes/origin/master
4. 创建本地分支
$ git pull origin master From ssh://192.168.1.2:29418/prj/shop * branch master -> FETCH_HEAD $ git branch -a * master remotes/origin/master
5. 将本地分支与远程分支关联起来
$ git branch --set-upstream-to=origin/master master Branch 'master' set up to track remote branch 'master' from 'origin'.
完成。
经过上述步骤操作后,操作此分支与操作直接通过 git clone 得到的分支是一样的了。