How can I achieve the next use git2go.
$ git checkout -b feature_branch_name
... edit files, add and commit ...
$ git push -u origin feature_branch_name
I'm stuck here:
branch, err = repo.CreateBranch("test", headCommit, false,
signature, "Test branch that I was to push immediately")
if err != nil {
panic(err)
}
UPDATE
Now I have the following: it creates a branch and points to the correct branch, but I cannot force it to update the working directory in the same way as git checkoutit does:
head, err := repository.Head()
if err != nil {
return err
}
headCommit, err := repository.LookupCommit(head.Target())
if err != nil {
return err
}
_, err = cs.repository.CreateBranch(name, headCommit, false)
if err != nil {
return err
}
_, err = cs.repository.References.CreateSymbolic("HEAD","refs/heads/"+name, true, "headOne")
if err != nil {
return err
}
opts := &git.CheckoutOpts{
Strategy: git.CheckoutSafe | git.CheckoutRecreateMissing,
}
if err := repository.CheckoutHead(opts); err != nil {
return err
}
I think I'm struggling with checkout options right now .
I'm still working on a button click.
source
share