Is there a way to commit part of modified files (all files are staged) by using libgit2sharp?

StackOverflow https://stackoverflow.com/questions/17742362

  •  03-06-2022
  •  | 
  •  

Question

Is there a way to commit part of modified files (all files are staged) by using libgit2sharp?

There are no Commit method in Repository that takes path parameter.

Was it helpful?

Solution

Is there a way to commit part of modified files (all files are staged) by using libgit2sharp?

Currently, there's no way to perform a partial staging/unstaging in LibGit2Sharp. I'd suggest you to subscribe to Issue 195 in order to be notified when this is available.

There are no Commit method in Repository that takes path parameter.

Actually, the action of committing consists of taking a snapshot of the Index and creating a durable Commit git object in the object database. As such, the Commit API doesn't accept paths.

In order to create a Commit from a file (or list of files) on your file system, you'd first have to add them to the Index with repo.Index.Stage(), then invoke the repo.Commit() method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top