public function checkoutAllRemoteBranches($remote = 'origin')
    {
        $actualBranch = $this->getMainBranch();
        $actualBranches = $this->getBranches(true, false);
        $allBranches = $this->getBranches(true, true);
        $realBranches = array_filter(
            $allBranches,
            function (string $branch) use ($actualBranches) {
                return !in_array($branch, $actualBranches)
                && preg_match('/^remotes(.+)$/', $branch)
                && !preg_match('/^(.+)(HEAD)(.*?)$/', $branch);
            }
        );

        foreach ($realBranches as $realBranch) {
            $this->checkout(str_replace(sprintf('remotes/%s/', $remote), '', $realBranch));
        }

        $this->checkout($actualBranch);

        return $this;
    }
public function checkoutAllRemoteBranches($remote = 'origin')
    {
        $actualBranch = $this->getMainBranch();
        $actualBranches = $this->getBranches(true, false);
        $allBranches = $this->getBranches(true, true);
        $realBranches = array_filter(
            $allBranches,
            function (string $branch) use ($actualBranches) {
                return !in_array($branch, $actualBranches)
                && preg_match('/^remotes(.+)$/', $branch)
                && !preg_match('/^(.+)(HEAD)(.*?)$/', $branch);
            }
        );

        foreach ($realBranches as $realBranch) {
            $this->checkout(str_replace(sprintf('remotes/%s/', $remote), '', $realBranch));
        }

        $this->checkout($actualBranch);

        return $this;
    }
public function checkoutAllRemoteBranches ( $ remote = 'origin' ) { $ actualBranch = $ this -> getMainBranch ( ) ; $ actualBranches = $ this -> getBranches ( true , false ) ; $ allBranches = $ this -> getBranches ( true , true ) ; $ realBranches = array_filter ( $ allBranches , function ( string $ branch ) use ( $ actualBranches ) { return ! in_array ( $ branch , $ actualBranches ) && preg_match ( '/^remotes(.+)$/' , $ branch ) && ! preg_match ( '/^(.+)(HEAD)(.*?)$/' , $ branch ) ; } ) ; foreach ( $ realBranches as $ realBranch ) { $ this -> checkout ( str_replace ( sprintf ( 'remotes/%s/' , $ remote ) , '' , $ realBranch ) ) ; } $ this -> checkout ( $ actualBranch ) ; return $ this ; }
Checkout all branches from the remote and make them local

@param string $remote remote to fetch from

@throws \RuntimeException
@throws \InvalidArgumentException
@throws \Symfony\Component\Process\Exception\RuntimeException
@return Repository
Checkout all branches from the remote and make them local