Fetch from the Git remote.

@param string      $remote
@param string|null $branch
@param string|null $dir
@param bool        $mustRun

@return bool
504322
public function fetch($remote, $branch = null, $dir = null, $mustRun = false)
    {
        $args = ['fetch', $remote];
        if ($branch !== null) {
            $args[] = $branch;
        }

        return (bool) $this->execute($args, $dir, $mustRun, false);
    }
132688
public function get($local_file, $remote_file, $overwrite = false)
    {
        if (false === $overwrite && true === file_exists($local_file)) {
            return $this->_trigger_error(sprintf('Local file already exists: %s.', $local_file));
        }

        $remote_file = $this->_getAbsoluteRemotePath($remote_file);
        if (false === file_exists($remote_file)) {
            return $this->_trigger_error(sprintf('Could not open remote file: %s.', $remote_file));
        }

        if (false === @copy($remote_file, $local_file)) {
            return $this->_trigger_error(sprintf('Could not send data from file %s to file %s.', $remote_file, $local_file));
        }

        return true;
    }
1014744
public function get_remote_api_branches( $git, $request ) {
		$branches = [];
		$response = isset( $this->response['branches'] ) ? $this->response['branches'] : false;

		if ( $this->exit_no_update( $response, true ) ) {
			return false;
		}

		if ( ! $response ) {
			self::$method = 'branches';
			$response     = $this->api( $request );
			$response     = $this->parse_response( $git, $response );

			if ( $this->validate_response( $response ) ) {
				return false;
			}

			if ( $response ) {
				$branches             = $this->parse_branch_response( $response );
				$this->type->branches = $branches;
				$this->set_repo_cache( 'branches', $branches );

				return true;
			}
		}

		$this->type->branches = $response;

		return true;
	}
464808
def is_remote_branch?(branch)
      branch_names = self.branches.remote.map {|b| b.name}
      branch_names.include?(branch)
    end
784540
public function get($remote_file, $local_file, $mode = null)
    {
        $mode = $mode ? $mode : FTP_ASCII;
        if (!@ftp_get($this->connection, $local_file, $remote_file, $mode)) {
            throw new \Exception("Could not get remote file:" . $remote_file);
        }

        return true;
    }
1048154
def _get_remote(self, cached=True):
        '''
        
        '''

        return self.m(
            'getting current remote',
            cmdd=dict(
                cmd='git remote show %s' % ('-n' if cached else ''),
                cwd=self.local
            ),
            verbose=False
        )
939767
public function pull($remote = 'origin', $branch = 'master')
    {
        if (!$this->hasCheckout) {
            throw new \RuntimeException('This operation requires an active checkout.');
        }

        return $this->execute('pull', array($remote, $branch));
    }
605623
def fetch(self):
        '''
        
        '''
        try:
            with self.gen_lock(lock_type='update'):
                log.debug('Fetching %s remote \'%s\'', self.role, self.id)
                # Run provider-specific fetch code
                return self._fetch()
        except GitLockError as exc:
            if exc.errno == errno.EEXIST:
                log.warning(
                    'Update lock file is present for %s remote \'%s\', '
                    'skipping. If this warning persists, it is possible that '
                    'the update process was interrupted, but the lock could '
                    'also have been manually set. Removing %s or running '
                    '\'salt-run cache.clear_git_lock %s type=update\' will '
                    'allow updates to continue for this remote.',
                    self.role,
                    self.id,
                    self._get_lock_file(lock_type='update'),
                    self.role,
                )
            return False
527662
def get_remote_revision(url, branch):
    
    proc = Process("git remote revision", ["git", "ls-remote", url, "refs/heads/" + branch])

    try:
        while True:
            raw_line = proc.stdout.pop()
            line = raw_line.strip().decode('utf8')
            if not line:
                continue
            return line.split("\t")[0]
    finally:
        try:
            proc.join()
        except Exception:
            pass
53956
def select_repo
      remote_urls = %x(git remote -v 2> /dev/null | awk '{print $2}' | uniq).split("\n")
      remote_urls << (I18n.t :other, scope: :negroku)

      question = I18n.t :choose_repo_url, scope: :negroku
      selected_idx = Ask.list question, remote_urls

      if selected_idx == remote_urls.length - 1
        question = I18n.t :type_repo_url, scope: :negroku
        Ask.input question
      else remote_urls[selected_idx] end
    end
624776
public function remoteBranchExists($remote, $branch)
    {
        $result = $this->processHelper->runCommand(['git', 'ls-remote', $remote], true);
        if (1 >= ($exists = preg_match_all('#(?<=\s)'.preg_quote('refs/heads/'.$branch, '#').'(?!\w)$#m', $result))) {
            return 1 === $exists;
        }

        throw new \RuntimeException(sprintf('Invalid refs found while searching for remote branch at "refs/heads/%s"', $branch));
    }
710546
def remotes_for_branches
      remotes = git_call('branch -lvv').gsub('* ', '').split("\n").map do |line|
        line.split(' ')[2][1..-2].split('/').first
      end
      remotes.uniq
    end
515660
def _get_branch(self, remotes=False):
        '''
        
        '''

        return self.m(
            'getting git branch information',
            cmdd=dict(
                cmd='git branch %s' % ('-r' if remotes else ''),
                cwd=self.local
            ),
            verbose=False
        )
3032
def fetch_commits(local_root, remotes):
    
    # Fetch all known branches.
    command = ['git', 'fetch', 'origin']
    run_command(local_root, command)

    # Fetch new branches/tags.
    for sha, name, kind in remotes:
        try:
            run_command(local_root, ['git', 'reflog', sha])
        except CalledProcessError:
            run_command(local_root, command + ['refs/{0}/{1}'.format(kind, name)])
            run_command(local_root, ['git', 'reflog', sha])
664870
protected function doGitInit(GitWorkingCopy $workingCopy, $url, $branch)
    {
        $workingCopy->init();
        $workingCopy->remote('add', 'origin', $url);

        try {

            $this->output->writeln("Attempting to fetch <path>origin/{$branch}</path>", OutputInterface::VERBOSITY_VERBOSE);

            $workingCopy
                ->fetch('origin', $branch)
                ->checkout('-f', $branch);

        } catch (GitException $exception) {

            $this->output->writeln("Fetch failed, creating new branch instead", OutputInterface::VERBOSITY_VERBOSE);

            $workingCopy
                ->checkout('--orphan', $branch)
                ->run(['commit', '--allow-empty', '-m', "Branch created by steak"])
                ->push('-u', 'origin', $branch);

        }

        return $workingCopy->clearOutput();
    }
261263
public function get($remote, $local)
    {
        foreach ($this->connections as $connection) {
            $connection->get($remote, $local);
        }
    }
577627
def get_remote_url(path, remote="origin"):
    
    path = get_path(path)
    cmd = ["config", "--get", "remote.%s.url" % remote]
    return __run_git(cmd, path)[0]