What HTTP Protocols does GIT use when cloning and pushing?
-
08-03-2021 - |
Question
I'm trying to use the LibGit2Sharp library resond to basic GIT commands such as clone and push with ASP.MVC and not sure how i should set up my controllers to respond accordingly.
Does GIT initiate a HTTP GET and POST request when cloning pushing? And should my controllers be set up like
[HttpGet]
public ActionResult Clone(string path)
{
//Return repo as stream?
}
[HttpPost]
public ActionResult Push(string path)
{
//Commit to repo
}
Thanks
Solution
From what I understand, you're trying to code something similar to git-daemon. Unfortunately, LibGit2Sharp doesn't implement network-related features yet.
Thus, it's not possible to serve push
, pull
, clone
or fetch
requests from ASP.Net MVC yet.
@synhershko 's issue in LibGit2Sharp tracker deals with a related subject: Proper pull, fetch, merge support
EDIT: If you wish to get a better understanding about Git transfer protocols from an HTTP perspective, I'd warmly recommend the following resources to start with:
Then, I'm afraid you'll have to dig into the code in order to get a better grasp of how it "works". My experience is that starting with JGit (java reimplementation of Git) code is a bit easier than a straight dive into the original Git C code. You'll find JGit transport related code here.