diff --git a/commands/command_lock.go b/commands/command_lock.go index ab88d7de..767f1b78 100644 --- a/commands/command_lock.go +++ b/commands/command_lock.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path/filepath" - "strings" "github.com/git-lfs/git-lfs/errors" "github.com/git-lfs/git-lfs/git" @@ -86,8 +85,13 @@ func lockPath(file string) (string, error) { } abs := filepath.Join(wd, file) - path := strings.TrimPrefix(abs, repo) - path = strings.TrimPrefix(path, string(os.PathSeparator)) + path, err := filepath.Rel(repo, abs) + if err != nil { + return "", err + } + + path = filepath.ToSlash(path) + if stat, err := os.Stat(abs); err != nil { return "", err } else {