豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
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