![]() ![]() The above example demonstrates the most commonly used Git repository information retrieval operations, there are many other operations, such as read and write ignore files via Repository.Ignore, write Commit, compare changes, and so on, you can explore on your own ?Ĭreative Commons Attribution-ShareAlike 4. We can get the full commit history via Branch.Commits or Repository.Commits foreach (var commit in repo.Commits) Of course, in addition to the name of the branch, it also includes other information such as Commits under the branch. For example, we want to output what local and remote branches are available in the current repository: using (var repo = new branches = repo.Branches This online CPU simulator is based on a simple educational model of a microcode-based CPU that was suggested by Heinz-Peter Gumm, Manfred Sommer, and Martin Perner in 1995. The Repository.Branches property contains all the branch information for the current repository. Opening the local Git repository is simple, passing the path to Repository's constructor: using (var repo = new Get Branch ![]() As my own blog project D:\GitHub\Moongladeīecause it implements the IDisposable interface, it is recommended that you use the using statement to wrap the operation on Repository to facilitate the release of resources. The LibGit2Sharp.Repository type represents a Git repository that can be loaded in memory or from a local path, that is, a directory that contains the ".git" folder. creates a ".git" hidden folder inside "D:\GitRocks". The Repository.Init() method can create a new Git repository in the specified path, equivalent to the git init command. Repository.Clone("", are overrides that can set advanced options. Repository.Clone() can download a remote repository to the local file system, same as git clone command. Now we have the fundamental library for everything we need. NET Core CLI dotnet add package LibGit2Sharp NuGet Package Manager (Visual Studio) Install-Package LibGit2Sharp NET Core, and that's what we need to use!įirst of all, let's install it into our. NET community already has a library that operates Git: LibGit2Sharp. We don't need to study the principles of Git from scratch. But on the server, you might need to manage a Git repository, have your own business logic, the Git repository needs to integrate with other system parts, and even want to write your own GitHub with ASP.NET, so it's useful to manipulate Git with. Why am I doing thisįirst of all, we do have a lot of good Git clients, such as GitHub for Windows, VS/VS Code, git GUI, and so on, all quite mature, there is no need for us to reinvent this wheel in own. I am going to show you how to operate Git with. Git is the preferred source code version control tool for many programmers, and I've recently switched from TFVC to Git.
0 Comments
Leave a Reply. |