2016-05-17 50 views
1

我是一个Git的新手。我一直在使用SVN,但是我正在处理的新项目存储在Git中。为单个分支设置Git

现在,我想在该存储库的单个分支上工作(让我们将其命名为'mybranch')(让我们假设www.example.com/project.git)。我已经做了以下内容:

git init 

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

但是,当我这样做时,它重新加载整个分支:

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

这需要永远的,因为已经有很多在那里。据我所知,它应该只是更新(取&合并)我有什么。像svn命令“更新”一样。

我一直在浏览教程和指导方针,现在已经有好几天了,我不知道这是怎么回事。

提前致谢!

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

$ git branch -avv 

回报什么,只是作为git remote -vgit branch -a

$ git config --local -l 

回报:

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

你能显示'git remote -v'和'git branch -a'的输出吗? –

+0

@StasMakarov Thorse什么都不返回,请参阅编辑问题。 – Saftkeks

回答

1

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

  1. 您当地的签出分支连接到远程上游分支

    git br -avv 
    * mybranch     c228c1a [origin/mybranch] 
    
  2. 你的回购应该只取该分支

    git config --local -l 
    [email protected]: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 

这将只提取并合并您的分支。

+0

谢谢你的时间。 'git br -avv'没有任何回应,'git config'等给了我一些看起来错误的东西。我编辑了上面的问题。 – Saftkeks

+0

@Saftkeks只需重新克隆您的repo并再次检查您的配置。 – VonC

+0

'致命的:目的地路径'项目名'已经存在,不是一个空目录。'我之前删除了该文件夹并再次克隆,这也没有做这项工作。我是否必须将该项目添加为远程? – Saftkeks

0

不要和git init之前的git clone,这将使嵌套的git回购。 git init将当前文件夹转换为git repo,git clone在当前文件夹内创建另一个git repo。

+0

Uhm我可以看到你在说什么,我现在有两个.git文件夹。但这能解决我的问题吗? – Saftkeks