为单个分支设置 Git

Setting up Git for a single branch

我是 Git 的新手。我一直在使用 SVN,但我正在处理的新项目存储在 Git.

现在,我想处理该存储库(假设 www.example.com/project.git)的单个分支(我们将其命名为 'mybranch')。我做了以下事情:

git init

git clone -b mybranch --single-branch www.example.com/project.git 

但是当我执行以下操作时,它会重新加载整个分支:

git pull www.example.com/project.git mybranch

这需要很长时间,因为里面已经有很多了。据我所知,它应该只是更新(获取和合并)我所拥有的。比如svn命令"update".

几天来我一直在浏览教程和操作方法,但我不知道到底发生了什么。

提前致谢!

-- 编辑 -- 我得到以下信息:

$ git branch -avv

returns 没什么,就像 git remote -vgit branch -a

$ git config --local -l

returns:

core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly

git clone -b mybranch --single-branch之后,你应该有两件事:

  1. 您本地签出的分支链接到远程上游分支

    git br -avv
    * mybranch                 c228c1a [origin/mybranch]
    
  2. 你的仓库应该只获取那个分支

    git config --local -l
    remote.origin.url=appgit@git.intramundi.com:qoa/jardepsg.git
    remote.origin.fetch=+refs/heads/pkgjarcls:refs/remotes/origin/pkgjarcls
    branch.pkgjarcls.remote=origin
    branch.pkgjarcls.merge=refs/heads/pkgjarcls
    

那样的话,你只需要

git pull

那只会获取并合并您的分支。

不要,在 git clone 之前 git init 是不必要的,这会形成一个嵌套的 git 回购。 git init 将当前文件夹变成一个 git 存储库,git clone 在当前文件夹中创建另一个 git 存储库。