Install LibGit2Sharp via NuGet
masterlibgit2 Git implementation. You can install it as a NuGet package to bring Git functionality to your .NET applications.repository·master·Indexed 25 days ago
https://github.com/libgit2/libgit2sharpA managed .NET wrapper for libgit2, a native Git implementation. It provides .NET developers with the ability to perform Git operations such as checkout, fetch, pull, stage, and index management with native code speed.
libgit2 Git implementation. You can install it as a NuGet package to bring Git functionality to your .NET applications.If you are running the LibGit2Sharp unit test suite, you can optimize performance on Windows by following these steps:
LibGit2TestPath environment variable to a specific path in your development environment. If the framework cannot find this folder at runtime, it falls back to the default location.LibGit2TestPath.LibGit2TestPath to point to it.If you encounter issues while using LibGit2Sharp, you can seek help through the following channels:
libgit2sharp tag.Commands.Fetch method to download objects and refs from a remote repository. The remote parameter can be either a configured remote name or a direct URL. You can provide FetchOptions to control behavior such as tag fetching, pruning, and custom headers.After making changes to the index, you must persist them:
Write(): Writes the current contents of the index to the disk.WriteToTree(): Writes the current contents of the index to a new Tree object and returns it.The Commands.Pull method fetches changes from the configured upstream remote and merges them into the branch pointed at by HEAD.
Requirements:
IsTracking must be true).RemoteName must not be null).Exceptions:
LibGit2SharpException if there is no tracking information for the current branch.LibGit2SharpException if there is no upstream remote for the current branch.The Index class provides several methods to overwrite its current state:
Replace(Tree source): Replaces all entries in the index with entries from the specified Tree.Replace(Commit commit): Replaces entries in the index with those from the specified Commit.Replace(Commit commit, IEnumerable<string> paths, ExplicitPathsOptions explicitPathsOptions): Replaces entries based on a commit, filtered by specific paths and options.Clear(): Removes all entries from the index, effectively resetting it to an empty state.The FetchOptions object allows you to customize the fetch operation. Key properties include:
TagFetchMode: Determines how tags are fetched. If not set, the library defaults to git_remote_autotag behavior.Prune: Controls whether stale remote-tracking branches are removed. Use FetchPruneStrategy.Prune to enable pruning or FetchPruneStrategy.NoPrune to disable it. If null, it defaults to FetchPruneStrategy.FromConfigurationOrDefault.CustomHeaders: An array of strings representing custom HTTP headers to include in the request.ProxyOptions: Configuration for proxy settings used during the fetch.Commit object. This will always result in a detached HEAD, making HEAD point directly to the commit's SHA.Use the Move command to move or rename files in the working directory and automatically promote the change to the staging area. This command performs both the filesystem move and the index update (removing the old path and adding the new path).
Note: Currently, this command does not support moving directories or moving a file into a directory; it is intended for file-to-file moves.
Index class represents the staging area between the working directory and the repository. It is used to prepare and aggregate changes for the next commit. You can iterate over the index to view IndexEntry objects, add files from the working directory, or add specific Blob objects.The Commands.Remove method allows you to remove files from the Git staging area (index). By default, it also removes the files from the working directory. If a file has already been deleted from the working directory, the method will simply promote that removal to the staging area.
Key Behaviors:
ExplicitPathsOptions, the provided path is treated as a pathspec (e.g., you can pass a folder path to remove all files and the folder itself).removeFromWorkingDirectory to false.RemoveFromIndexException if you attempt to remove a file that has staged changes or local modifications while removeFromWorkingDirectory is set to true.