Skip to content

LibGit2Sharp Hitchhiker's Guide to Git

treischl edited this page May 24, 2016 · 15 revisions

LibGit2Sharp Hitchhiker's Guide to Git

This page lists the standard git commands and, when available, links to code samples describing how to leverage LibGit2Sharp in order to replicate their behavior.

Please, keep in mind that this document is a work in progress. It's not in sync with the current state of the library which is able to handle much more than what is linked below.

Note: The list of the git commands and their descriptions has been scraped from the official git man page.

High-level commands (porcelain)

Main porcelain commands

  • git-add (Add file contents to the index.)
  • git-am (Apply a series of patches from a mailbox.)
  • git-archive (Create an archive of files from a named tree.)
  • git-bisect (Find by binary search the change that introduced a bug.)
  • git-branch (List, create, or delete branches.)
  • git-bundle (Move objects and refs by archive.)
  • git-checkout (Checkout a branch or paths to the working tree.)
  • git-cherry-pick (Apply the changes introduced by some existing commits.)
  • git-citool (Graphical alternative to git-commit.)
  • git-clean (Remove untracked files from the working tree.)
  • git-clone (Clone a repository into a new directory.)
  • git-commit (Record changes to the repository.)
  • git-describe (Show the most recent tag that is reachable from a commit.)
  • git-diff (Show changes between commits, commit and working tree, etc.)
  • git-fetch (Download objects and refs from another repository.)
  • git-format-patch (Prepare patches for e-mail submission.)
  • git-gc (Cleanup unnecessary files and optimize the local repository.)
  • git-grep (Print lines matching a pattern.)
  • git-gui (A portable graphical interface to Git.)
  • git-init (Create an empty git repository or reinitialize an existing one.)
  • git-log (Show commit logs.)
  • git-merge (Join two or more development histories together.)
  • git-mv (Move or rename a file, a directory, or a symlink.)
  • git-notes (Add or inspect object notes.)
  • git-pull (Fetch from and merge with another repository or a local branch.)
  • git-push (Update remote refs along with associated objects.)
  • git-rebase (Forward-port local commits to the updated upstream head.)
  • git-reset (Reset current HEAD to the specified state.)
  • git-revert (Revert some existing commits.)
  • git-rm (Remove files from the working tree and from the index.)
  • git-shortlog (Summarize git log output.)
  • git-show (Show various types of objects.)
  • git-stash (Stash the changes in a dirty working directory away.)
  • git-status (Show the working tree status.)
  • git-submodule (Initialize, update or inspect submodules.)
  • git-tag (Create, list, delete or verify a tag object signed with GPG.)
  • gitk (The git repository browser.)

Ancillary Commands

1.Manipulators

  • git-config (Get and set repository or global options.)
  • git-fast-export (Git data exporter.)
  • git-fast-import (Backend for fast Git data importers.)
  • git-filter-branch (Rewrite branches.)
  • git-lost-found ((deprecated) Recover lost refs that luckily have not yet been pruned.)
  • git-mergetool (Run merge conflict resolution tools to resolve merge conflicts.)
  • git-pack-refs (Pack heads and tags for efficient repository access.)
  • git-prune (Prune all unreachable objects from the object database.)
  • git-reflog (Manage reflog information.)
  • git-relink (Hardlink common objects in local repositories.)
  • git-remote (manage set of tracked repositories.)
  • git-repack (Pack unpacked objects in a repository.)
  • git-replace (Create, list, delete refs to replace objects.)
  • git-repo-config ((deprecated) Get and set repository or global options.)

2.Interrogators

  • git-annotate (Annotate file lines with commit information.)
  • git-blame (Show what revision and author last modified each line of a file.)
  • git-cherry (Find commits not merged upstream.)
  • git-count-objects (Count unpacked number of objects and their disk consumption.)
  • git-difftool (Show changes using common diff tools.)
  • git-fsck (Verifies the connectivity and validity of the objects in the database.)
  • git-get-tar-commit-id (Extract commit ID from an archive created using git-archive.)
  • git-help (display help information about git.)
  • git-instaweb (Instantly browse your working repository in gitweb.)
  • git-merge-tree (Show three-way merge without touching index.)
  • git-rerere (Reuse recorded resolution of conflicted merges.)
  • git-rev-parse (Pick out and massage parameters.)
  • git-show-branch (Show branches and their commits.)
  • git-verify-tag (Check the GPG signature of tags.)
  • git-whatchanged (Show logs with difference each commit introduces.)

Interacting with Others

These commands are to interact with foreign SCM and with other people via patch over e-mail.

  • git-archimport (Import an Arch repository into git.)
  • git-cvsexportcommit (Export a single commit to a CVS checkout.)
  • git-cvsimport (Salvage your data out of another SCM people love to hate.)
  • git-cvsserver (A CVS server emulator for git.)
  • git-imap-send (Send a collection of patches from stdin to an IMAP folder.)
  • git-quiltimport (Applies a quilt patchset onto the current branch.)
  • git-request-pull (Generates a summary of pending changes.)
  • git-send-email (Send a collection of patches as emails.)
  • git-svn (Bidirectional operation between a Subversion repository and git.)

Low-level commands (plumbing)

Although git includes its own porcelain layer, its low-level commands are sufficient to support development of alternative porcelains. Developers of such porcelains might start by reading about git-update-index and git-read-tree.

The interface (input, output, set of options and the semantics) to these low-level commands are meant to be a lot more stable than Porcelain level commands, because these commands are primarily for scripted use. The interface to Porcelain commands on the other hand are subject to change in order to improve the end user experience.

The following description divides the low-level commands into commands that manipulate objects (in the repository, index, and working tree), commands that interrogate and compare objects, and commands that move objects and references between repositories.

Manipulation commands

  • git-apply (Apply a patch to files and/or to the index.)
  • git-checkout-index (Copy files from the index to the working tree.)
  • git-commit-tree (Create a new commit object.)
  • git-hash-object (Compute object ID and optionally creates a blob from a file.)
  • git-index-pack (Build pack index file for an existing packed archive.)
  • git-merge-file (Run a three-way file merge.)
  • git-merge-index (Run a merge for files needing merging.)
  • git-mktag (Creates a tag object.)
  • git-mktree (Build a tree-object from ls-tree formatted text.)
  • git-pack-objects (Create a packed archive of objects.)
  • git-prune-packed (Remove extra objects that are already in pack files.)
  • git-read-tree (Reads tree information into the index.)
  • git-symbolic-ref (Read and modify symbolic refs.)
  • git-unpack-objects (Unpack objects from a packed archive.)
  • git-update-index (Register file contents in the working tree to the index.)
  • git-update-ref (Update the object name stored in a ref safely.)
  • git-write-tree (Create a tree object from the current index.)

Interrogation commands

  • git-cat-file (Provide content or type and size information for repository objects.)
  • git-diff-files (Compares files in the working tree and the index.)
  • git-diff-index (Compares content and mode of blobs between the index and repository.)
  • git-diff-tree (Compares the content and mode of blobs found via two tree objects.)
  • git-for-each-ref (Output information on each ref.)
  • git-ls-files (Show information about files in the index and the working tree.)
  • git-ls-remote (List references in a remote repository.)
  • git-ls-tree (List the contents of a tree object.)
  • git-merge-base (Find as good common ancestors as possible for a merge.)
  • git-name-rev (Find symbolic names for given revs.)
  • git-pack-redundant (Find redundant pack files.)
  • git-rev-list (Lists commit objects in reverse chronological order.)
  • git-show-index (Show packed archive index.)
  • git-show-ref (List references in a local repository.)
  • git-tar-tree ((deprecated) Create a tar archive of the files in the named tree object.)
  • git-unpack-file (Creates a temporary file with a blob’s contents.)
  • git-var (Show a git logical variable.)
  • git-verify-pack (Validate packed git archive files.)

In general, the interrogate commands do not touch the files in the working tree.

Synching repositories

  • git-daemon (A really simple server for git repositories.)
  • git-fetch-pack (Receive missing objects from another repository.)
  • git-http-backend (Server side implementation of Git over HTTP.)
  • git-send-pack (Push objects over git protocol to another repository.)
  • git-update-server-info (Update auxiliary info file to help dumb servers.)

The following are helper commands used by the above; end users typically do not use them directly.

  • git-http-fetch (Download from a remote git repository via HTTP.)
  • git-http-push (Push objects over HTTP/DAV to another repository.)
  • git-parse-remote (Routines to help parsing remote repository access parameters.)
  • git-receive-pack (Receive what is pushed into the repository.)
  • git-shell (Restricted login shell for Git-only SSH access.)
  • git-upload-archive (Send archive back to git-archive.)
  • git-upload-pack (Send objects packed back to git-fetch-pack.)

Internal helper commands

These are internal helper commands used by other commands; end users typically do not use them directly.

  • git-check-attr (Display gitattributes information.)
  • git-check-ref-format (Ensures that a reference name is well formed.)
  • git-fmt-merge-msg (Produce a merge commit message.)
  • git-mailinfo (Extracts patch and authorship from a single e-mail message.)
  • git-mailsplit (Simple UNIX mbox splitter program.)
  • git-merge-one-file (The standard helper program to use with git-merge-index.)
  • git-patch-id (Compute unique ID for a patch.)
  • git-peek-remote ((deprecated) List the references in a remote repository.)
  • git-sh-setup (Common git shell script setup code.)
  • git-stripspace (Filter out empty lines.)