Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$repo->checkout can't specify amongst multiple remote branches. (Solution code included) #58

Open
John-Schlick opened this issue Aug 4, 2014 · 0 comments
Labels

Comments

@John-Schlick
Copy link
Contributor

Please see the article at:
http://makandracards.com/makandra/14323-git-how-to-check-out-branches-that-exist-on-multiple-remotes

It talks about how to specify amongst remote branches at checkout. Since you also dont support git checkout -b thats included as it's necessary to get teh right syntax.

If you change mainCommand->checkout to look like this:
public function checkout($ref, $createBranch = false, $refSource=null)
{
$this->clearAll();

    $what = $ref;
    if ($ref instanceof Branch) {
        $what = $ref->getName();
    } elseif ($ref instanceof TreeishInterface) {
        $what = $ref->getSha();
    }

    $this->addCommandName(self::GIT_CHECKOUT);
    $this->addCommandArgument('-q');
    if ($createBranch) {
        $this->addCommandArgument('-b');
    }
    $this->addCommandSubject($what);
    if (!is_null($refSource)) {
        $this->addCommandSubject2($refSource);
    }
    return $this->getCommand();
}

and then change repository->checkout to look like:
public function checkout($ref, $createBranch = false, $refSource=null)
{
$this->caller->execute(MainCommand::getInstance()->checkout($ref, $createBranch, $refSource));

    return $this;
}

This will allow a caller to specify a SPECIFIC source for their checkout (if the local branch does not already exist.), as well as specifying that they want a branch created.

@John-Schlick John-Schlick changed the title $repo->checkout can't specify amongst multiple remote branches. $repo->checkout can't specify amongst multiple remote branches. (Solution code included) Aug 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants