git-gsub is using regexp package for replacing string, which depends on re2 and re2 doesn't support submatch. Replacing with submatch is undocumented(yet partially test) feature, but I hope this to be supported officially. Failing test case can be seen in #22. [regexp package - regexp - pkg.go.dev]( https://pkg.go.dev/regexp ) [Syntax · google/re2 Wiki]( https://github.com/google/re2/wiki/Syntax )