Fetch a path from git. args can be a URL, in which case the HEAD of the repo at that URL is fetched. Otherwise, it can be an attribute with the following attributes (all except url optional):

The return value is an attrset containing the following keys:

A full example of the output:

{
  lastModified = 1746827286;
  lastModifiedDate = "20250509214806";
  narHash = "sha256-qCRBy8Bbh5XhPalPkhonxNgfsbw3lP0UIXBLSrhxAvI=";
  outPath = "/nix/store/2qdnzhzccspwm70mni7jkvrfkpwcb3jn-source";
  rev = "dcb0a97000d50b2868ed4f8d9fd465c5a5b8eb3a";
  revCount = 17845;
  shortRev = "dcb0a97";
  submodules = false;
}

Here are some examples of how to use fetchGit.

If the URL points to a local directory, and no ref or rev is given, fetchGit will use the current content of the checked-out files, even if they are not committed or added to Git's index. It will only consider files added to the Git repository, as listed by git ls-files.