Skip to content
DorloBorlo edited this page Dec 8, 2023 · 4 revisions

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

Move

Move a file to a new location.

Git

$ git mv <file> <new/path>

LibGit2Sharp

using (var repo = new Repository("<repoPath>"))
{
    // Moves the file. Path must be in Posix format (using '/' as path separator)
    Commands.Move(repo, "<file>", "<new/path>")
}

Rename

Rename a file.

Git

$ git mv <file> <path/to/file>/<newname>

LibGit2Sharp

using (var repo = new Repository("<repoPath>"))
{
    // Renames the file. Path must be in Posix format (using '/' as path separator)
    Commands.Move(repo, "<file>", "<path/to/file>/<newname>")
}
Clone this wiki locally