Clone a git repo from a specific ref
424193
function cloneGitRepo(host, ref) {
    var isBranch = false;

    ref = ref || 'master';
    if (!validateSha(ref)) isBranch = true;

    return Q()

    // Create temporary folder to store git repos
    .then(function() {
        if (GIT_TMP) return;
        return fs.tmp.dir()
            .then(function(_tmp) {
                GIT_TMP = _tmp;
            });
    })

    // Return or clone the git repo
    .then(function() {
        // Unique ID for repo/ref combinaison
        var repoId = crc.crc32(host+'#'+ref).toString(16);

        // Absolute path to the folder
        var repoPath = path.resolve(GIT_TMP, repoId);

        return fs.exists(repoPath)
            .then(function(doExists) {
                if (doExists) return;

                // Clone repo
                return exec('git clone '+host+' '+repoPath)
                .then(function() {
                    return exec('git checkout '+ref, { cwd: repoPath });
                });
            })
            .thenResolve(repoPath);
    });
}
902040
def clone(cls, srcpath, destpath, encoding='utf-8'):
        """"""
        cmd = [GIT, 'clone', '--quiet', '--bare', srcpath, destpath]
        subprocess.check_call(cmd)
        return cls(destpath, encoding)
385115
def initialize_repo(self):
        

        logging.info('Repo {} doesn\'t exist. Cloning...'.format(self.repo_dir))
        clone_args = ['git', 'clone']
        if self.depth and self.depth > 0:
            clone_args.extend(['--depth', str(self.depth)])
        clone_args.extend(['--branch', self.branch_name])
        clone_args.extend([self.git_url, self.repo_dir])
        yield from execute_cmd(clone_args)
        yield from execute_cmd(['git', 'config', 'user.email', 'nbgitpuller@example.com'], cwd=self.repo_dir)
        yield from execute_cmd(['git', 'config', 'user.name', 'nbgitpuller'], cwd=self.repo_dir)
        logging.info('Repo {} initialized'.format(self.repo_dir))
638614
function cloneItree(itree, excludeKeys) {
    const clone = {};
    excludeKeys = _.castArray(excludeKeys);
    excludeKeys.push('ref');

    _.each(itree, (v, k) => {
        if (!_.includes(excludeKeys, k)) {
            clone[k] = _.cloneDeep(v);
        }
    });

    return clone;
}
595771
def re_clone(self, repo_dir):
        """"""
        self.git('clone', self.remote_url, repo_dir)
        return GitRepo(repo_dir)
638683
function clone() {
		Release.chdir( Release.dir.base );
		Release.dir.dist = Release.dir.base + "/dist";

		console.log( "Using distribution repo: ", distRemote );
		Release.exec( "git clone " + distRemote + " " + Release.dir.dist,
			"Error cloning repo." );

		// Distribution always works on master
		Release.chdir( Release.dir.dist );
		Release.exec( "git checkout master", "Error checking out branch." );
		console.log();
	}
7439
def git_pull(repo_dir, remote="origin", ref=None, update_head_ok=False):
    """"""
    command = ['git', 'pull']
    if update_head_ok:
        command.append('--update-head-ok')
    command.append(pipes.quote(remote))
    if ref:
        command.append(ref)
    return execute_git_command(command, repo_dir=repo_dir)
497889
function cloneRepo(item){

      var deferred = Q.defer();
      var repoURL = item.repo;
      var path = item.path;

      deleteOldFiles(path).
      then(function(){
        return performCmd(repoURL, path);
      }).then(function(success){
        return npmInstall(path, success);
      }).then(function(success){
        return bowerInstall(path, success);
      }).then(function(){
        deferred.resolve();
      });

      return deferred.promise;

    }
1081466
def clone_or_update
      if File.directory?(@dir + "/.git")
        if Git.open(@dir).remote.url == @config.repository_url
          update
        else
          clone
        end
      else
        clone
      end

      @repo.checkout(@config.branch)
    end
959384
def commit_deltas_from(other_repo, ref = "master", other_ref = "master")
      # TODO: we should be able to figure out the branch point, rather than
      # rev-list'ing the whole thing
      repo_refs       = self.git.rev_list({}, ref).strip.split("\n")
      other_repo_refs = other_repo.git.rev_list({}, other_ref).strip.split("\n")

      (other_repo_refs - repo_refs).map do |refn|
        Commit.find_all(other_repo, refn, {:max_count => 1}).first
      end
    end
1278813
def git_pull_view(self, request, repo_name):
        """"""
        LOG.info("Pull requested for %s." % repo_name)
        repo = get_object_or_404(self.model, name=repo_name)
        repo.pull()
        self.message_user(request, "Repo %s successfully updated." % repo_name,
                          level=messages.SUCCESS)
        return redirect('admin:registry_clonedrepo_change', repo_name)
1251328
def refs_list
      refs = self.git.for_each_ref
      refarr = refs.split("\n").map do |line|
        shatype, ref = line.split("\t")
        sha, type = shatype.split(' ')
        [ref, sha, type]
      end
      refarr
    end
1077072
def update_repo(repo_dir, repo_url, fetch=False):
    """"""
    repo_exists = os.path.exists(repo_dir)
    if not repo_exists:
        log.info("Cloning repo {}".format(repo_url))
        repo = repo_clone(repo_dir, repo_url)

    # Make sure the repo is properly prepared
    # and has all the refs required
    log.info("Fetching repo {} (fetch: {})".format(repo_url, fetch))
    repo = repo_pull(repo_dir, repo_url, fetch)

    return repo
153520
def git_clone(sub_repo, branch, commit = None, cwd = None, no_submodules = False):
        '''
        
        '''
        if not cwd:
            cwd = cwd = os.getcwd()
        root_dir = os.path.join(cwd,'boostorg',sub_repo)
        if not os.path.exists(os.path.join(root_dir,'.git')):
            utils.check_call("git","clone",
                "--depth=1",
                "--branch=%s"%(branch),
                "https://github.com/boostorg/%s.git"%(sub_repo),
                root_dir)
            os.chdir(root_dir)
        else:
            os.chdir(root_dir)
            utils.check_call("git","pull",
                # "--depth=1", # Can't do depth as we get merge errors.
                "--quiet","--no-recurse-submodules")
        if commit:
            utils.check_call("git","checkout","-qf",commit)
        if os.path.exists(os.path.join('.git','modules')):
            if sys.platform == 'win32':
                utils.check_call('dir',os.path.join('.git','modules'))
            else:
                utils.check_call('ls','-la',os.path.join('.git','modules'))
        if not no_submodules:
            utils.check_call("git","submodule","--quiet","update",
                "--quiet","--init","--recursive",
                )
            utils.check_call("git","submodule","--quiet","foreach","git","fetch")
        return root_dir
375718
def git_clone(uri, pull=True, reflect=False, cache_dir=None, chdir=True):
    '''
    
    '''
    cache_dir = cache_dir or CACHE_DIR
    # make the uri safe for filesystems
    repo_path = os.path.expanduser(os.path.join(cache_dir, safestr(uri)))
    if not os.path.exists(repo_path):
        from_cache = False
        logger.info(
            'Locally caching git repo [%s] to [%s]' % (uri, repo_path))
        cmd = 'git clone %s %s' % (uri, repo_path)
        sys_call(cmd)
    else:
        from_cache = True
        logger.info(
            'GIT repo loaded from local cache [%s])' % (repo_path))
    if pull and not from_cache:
        os.chdir(repo_path)
        cmd = 'git pull'
        sys_call(cmd, cwd=repo_path)
    if chdir:
        os.chdir(repo_path)
    if reflect:
        if not HAS_DULWICH:
            raise RuntimeError("`pip install dulwich` required!")
        return Repo(repo_path)
    else:
        return repo_path
1373475
def clone_from(repo_url, repo_dir):
    """"""
    repo_url = _fix_repo_url(repo_url)
    LOG.info("Cloning %s into %s." % (repo_url, repo_dir))
    cmd = GIT_CLONE_CMD.format(repo_url, repo_dir)
    resp = envoy.run(cmd)
    if resp.status_code != 0:
        LOG.error("Cloned failed: %s" % resp.std_err)
        raise GitException(resp.std_err)
    LOG.info("Clone successful.")
1205635
def clone(giturl, gitpath):
    
    gitArgs = ['git', 'clone', giturl, gitpath]
    slog.info(' '.join(gitArgs))
    return subprocess.call(gitArgs)