docs: Adds documentation on how to create a branch (#2541)

This commit is contained in:
Chris Simpson
2022-08-11 07:35:54 +01:00
committed by GitHub
parent 1e3fa1d770
commit b4ca7c7c57

View File

@@ -1,5 +1,19 @@
# Working with the Git Database
### Create a Branch
Branches can be created through the Git client. These are known as References. To create a reference, the first property you need is the name of the branch you want to create. You must ensure the reference starts with "refs" and contain two "/", otherwise it will be rejected. The second property is the SHA of the commit you want to branch from. This can be any commit but it must exist in the repository to be accepted.
```csharp
var reference = new NewReference($"refs/heads/{branchName}", commit.Sha);
```
You can then create the Reference using the Reference.Create Api, either passing in the Repository Owner and Name or the Repository Id.
```csharp
var branch = await github.Git.Reference.Create(owner, repo, reference);
var branch = await github.Git.Reference.Create(id, reference);
```
### Tag a Commit
Tags can be created through the GitHub API