Skip to content

Commands.Move is different from git mv #2174

@mpelley

Description

@mpelley

If I use git mv from the command line, I do not lose my history. It is a rename in the history.

If I use Commands.Move it looks in the git log like a file delete and a file create, therefore losing my history. The file is renamed in the file system, but git didn't see the rename.

I'm using libgit2sharp version 0.31.0 with VS 2022 building with .NET 8 and C# version 13 on Windows 11.

My code looks like:

try
{
    using (var repo = new Repository(repoRoot))
    {
        // Moves the file. Path must be in Posix format (using '/' as path separator)
        Commands.Move(repo, oldPath, newPath);
        ok = true;
    }
}
catch (Exception ex)
{
    Error = "Git Move exception: " + ex.Message;
}

Am I doing something wrong? I convert the Windows path format to Posix format before using them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions