Skip to content
Karel Kral edited this page Jul 2, 2021 · 3 revisions

The following examples assume you already have a repository in place to work with. If not, see git-init.

Remove from a Initialized Repository

This will stage the specified file for removal from the Repo:

Git

$ git rm <file>

LibGit2Sharp

using (var repo = new Repository("<repoPath>"))
{
    // Removes the file. Path must be in Posix format (using '/' as path separator)
    repo.Index.Remove("<file>");
}

Example Code:

using (var repo = new Repository("<repoPath>"))
{
    // Create the committer's signature and commit
    Signature author = new Signature("Author", "@Author", DateTime.Now);
    Signature committer = author;

    // Remove the file. Path must be in Posix format (using '/' as path separator)
    repo.Index.Remove("<file>");

    // Commit to the repository
    Commit commit = repo.Commit(message, author, committer);
}
Clone this wiki locally
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy