libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

how to checkout -b branch

Open NikkyAI opened this issue 8 years ago • 1 comments

apparently i am only able to checkout a branch and have it be detached.. is there a way to create a local branch with proper remote tracking info ?

NikkyAI avatar May 08 '17 15:05 NikkyAI

You'd need to create the new branch using the CreateBranch method, then check it out.

Something like this based on info found in the wiki.

using (var repo = new Repository("path/to/your/repo"))
{
    Branch branch = repo.CreateBranch("develop");   // Or repo.Branches.Add("develop", "HEAD");

    Branch currentBranch = Commands.Checkout(repo , branch);
}

rubberduck203 avatar Jul 09 '17 22:07 rubberduck203