diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go
index fe3b6598d7..70f6ef9dbb 100644
--- a/modules/git/log_name_status.go
+++ b/modules/git/log_name_status.go
@@ -56,6 +56,10 @@ func LogNameStatusRepo(ctx context.Context, repository, head, treepath string, p
 	} else if treepath != "" {
 		files = append(files, treepath)
 	}
+	// Use the :(literal) pathspec magic to handle edge cases with files named like ":file.txt" or "*.jpg"
+	for i, file := range files {
+		files[i] = ":(literal)" + file
+	}
 	cmd.AddDashesAndList(files...)
 
 	go func() {