Put the publish.gradle.kts file next to your build.gradle.
Edit the RepoURL and RepoBranch properties. (each time you change these, make sure to delete the build/maven folder!)
Add apply from: 'publish.gradle.kts' (Groovy) or apply { from("publish.gradle.kts") } (Kotlin) to your build.gradle.
Test if everything works by executing the updateLocalRepo task, there should now be a git repository in build/maven.