为单个分支设置Git

时间:2016-05-17 07:45:46

标签: git branch pull

我是Git的新手。我一直在使用SVN,但我正在处理的新项目存储在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命令“update”。

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

提前致谢!

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

$ 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

2 个答案:

答案 0 :(得分:1)

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
    
  3. 在这种情况下,您只需要

    git pull
    

    这将仅获取并合并您的分支。

答案 1 :(得分:0)

git init git clone之前,git init是不可能的,这会产生一个嵌套的git repo。 git clone将当前文件夹转换为git repo,#include <iostream> #include <string> typedef unsigned int uint; typedef std::string::iterator seq_iterator; std::string FindCombinations(seq_iterator current, seq_iterator end, uint comb_length, std::string comb) { if (comb_length == 0 || comb_length > std::distance(current, end)) return comb;//no more possible combinations auto next = current + 1; std::string with; if (std::distance(next, end) >= comb_length - 1) with = FindCombinations(next, end, comb_length - 1, comb + *current);//use current in combination std::string without; if (std::distance(next, end) >= comb_length) without = FindCombinations(next, end, comb_length, comb);//skip current in combination std::string result = with; if (!result.empty() && !without.empty()) result += ' '; return result + without; } int main() { std::string seq = "ABCDE"; std::cout << FindCombinations(seq.begin(), seq.end(), 2, "") << std::endl; } 在当前文件夹中生成另一个git repo。