@param Remote|string $remote
@param Branch|string $branch

@throws \RuntimeException
@return string
545430
public function push($remote = 'origin', $branch = 'master', string $args = null)
    {
        if ($remote instanceof Remote) {
            $remote = $remote->getName();
        }
        if ($branch instanceof Branch) {
            $branch = $branch->getName();
        }
        $this->clearAll();
        $this->addCommandName(self::GIT_PUSH_COMMAND);
        $this->addCommandSubject($remote);
        $this->addCommandSubject2($branch);

        if(!is_null($args)) {
            $this->addCommandArgument($args);
        }

        return $this->getCommand();
    }
12662
public function fetch($remote = null, $branch = null, Array $options = array())
    {
        if ($remote instanceof Remote) {
            $remote = $remote->getName();
        }
        if ($branch instanceof Branch) {
            $branch = $branch->getName();
        }
        $normalizedOptions = $this->normalizeOptions($options, $this->fetchCmdSwitchOptions());

        $this->clearAll();
        $this->addCommandName(self::GIT_FETCH_COMMAND);

        foreach ($normalizedOptions as $value) {
            $this->addCommandArgument($value);
        }

        if (!is_null($remote)) {
            $this->addCommandSubject($remote);
        }
        if (!is_null($branch)) {
            $this->addCommandSubject2($branch);
        }

        return $this->getCommand();
    }
843511
public function getFullTagDataByRemoteId($remoteId, array $translations = null, $useAlwaysAvailable = true)
    {
        try {
            return $this->innerGateway->getFullTagDataByRemoteId($remoteId, $translations, $useAlwaysAvailable);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
547940
protected function validateBranch($branch)
    {
        try {
            if (!strpos($branch, '/')) {
                return false;
            }
            return $this->versionParser->normalizeBranch(
                $this->_getBranchWithoutNamespace($branch)
            );
        } catch (\Exception $e) {
            return false;
        }
    }
289014
def remote_for_branch(branch_name)
      git_call('branch -lvv').gsub('* ', '').split("\n").each do |line|
        entries = line.split(' ')
        next unless entries.first == branch_name
        # Return the remote name or nil for local branches.
        match = entries[2].match(%r(\[(.*)(\]|:)))
        return match[1].split('/').first if match
      end
      nil
    end
578395
public function getLastChild(Branch $branch = null)
    {
        if (null === $branch) {
            return null;
        }

        //end return last child or false if is not found
        $children = $branch->getChildren();
        $last = end($children);

        return $last ? $last : null;
    }
734386
public function branch($branch, $stash)
    {
        $stash = $this->normalizeStashName($stash);
        $this->clearAll();
        $this->addCommandName(self::STASH_COMMAND . ' branch');
        $this->addCommandSubject($branch);
        $this->addCommandSubject2($stash);
        return $this->getCommand();
    }
895488
public function get($remotePathname, $localPathname)
    {
        if (!$this->getScp()->get($remotePathname, $localPathname)) {
            throw new \RuntimeException(sprintf('Unable to get file "%s".', $remotePathname));
        }

        return $this;
    }
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
1080811
public void cloneBranch(String branch) throws Exception {
        CloneCommand cloneCommand = Git.cloneRepository()
                .setURI(repositoryUrl)
                .setDirectory(localRepo.getDirectory().getParentFile())
                .setBranchesToClone(Arrays.asList(branch))
                .setCloneAllBranches(false)
                .setBranch(branch);
        if (credentialsProvider != null)
            cloneCommand.setCredentialsProvider(credentialsProvider);
        Git git = cloneCommand.call();
        git.getRepository().close();
        git.close();
    }
954619
protected String branchRefForName( String branchName ) {
        String remoteName = connector.remoteName();
        return remoteName != null ? remoteBranchPrefix(remoteName) + branchName : LOCAL_BRANCH_PREFIX + branchName;
    }
527167
public function guessParentBranchAsCommitHash(string $branchName = 'HEAD') : string
    {
        $initialNumberOfContainingBranches = $this->getCountOfContainingBranches($branchName);
        while ($this->isParentCommitishACommit($branchName)) {
            $branchName .= '^';
            $numberOfContainingBranches = $this->getCountOfContainingBranches($branchName);

            if ($numberOfContainingBranches !== $initialNumberOfContainingBranches) {
                break;
            }
        }
        $gitCommitHash = $this->processRunner->runAsProcess('git', 'rev-parse', $branchName);

        return $gitCommitHash;
    }
624952
def validate_target_remote_branch
      remote_path = File.join(config[:remote], config[:branch])

      remotes = []
      @gitrepo.remotes.each { |remote| remotes << remote.name }
      unless remotes.include?(remote_path)
        ui.error 'The remote/branch specified does not seem to exist.'
        exit 7
      end
    end
67061
protected static function simpleMerge(string $base, string $remote, string $local)
    {
        // Skip complex merging if there is nothing to do.
        if ($base == $remote) {
            return $local;
        }
        if ($base == $local) {
            return $remote;
        }
        if ($remote == $local) {
            return $remote;
        }
        // Return nothing and let sub-classes deal with it.
        return null;
    }
913007
def push(self, remote, branch=None):
        '''
        '''
        pb = ProgressBar()
        pb.setup(self.name, ProgressBar.Action.PUSH)
        if branch:
            result = remote.push(branch, progress=pb)
        else: #pragma: no cover
            result = remote.push(progress=pb)
        print()
        return result, pb.other_lines
663701
protected function copyBranch($branch, $parentId) {
        $Model = $this->Model;

        $copy = new $Model($branch->attributesToArray());
        $copy->parentId = $parentId;
        $copy->save();
        $parentId = $copy->id;

        foreach ( $branch->children as $child ) {
            $this->copyBranch($child, $parentId);
        }

        return $copy;
    }
1254460
def get_url(self):
        '''
        
        '''
        if self.role in ('git_pillar', 'winrepo'):
            # With winrepo and git_pillar, the remote is specified in the
            # format '<branch> <url>', so that we can get a unique identifier
            # to hash for each remote.
            try:
                self.branch, self.url = self.id.split(None, 1)
            except ValueError:
                self.branch = self.conf['branch']
                self.url = self.id
        else:
            self.url = self.id