Trying to create a new branch and push it to my remote repo using this code:
var localBranch = repository.CreateBranch(environment);
Commands.Checkout(repository, localBranch);
var remote = repository.Network.Remotes.First();
repository.Branches.Update(localBranch, b => b.Remote = remote.Name, b => b.UpstreamBranch = localBranch.CanonicalName);
repository.Network.Push(localBranch, pushOptions);
Unfortunately I am getting the following exception:
LibGit2Sharp.BareRepositoryException: local push doesn't (yet) support pushing to non-bare repos.
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_remote_push(RemoteHandle remote, IEnumerable`1 refSpecs, GitPushOptions opts)
at LibGit2Sharp.Network.Push(Remote remote, IEnumerable`1 pushRefSpecs, PushOptions pushOptions)
at LibGit2Sharp.Network.Push(Remote remote, String pushRefSpec, PushOptions pushOptions)
at LibGit2Sharp.Network.Push(IEnumerable`1 branches, PushOptions pushOptions)
at LibGit2Sharp.Network.Push(Branch branch, PushOptions pushOptions)
What am I missing? isn't it possible to push a new branch to a remote repository?