If we can make this code its own app, then you can create a module in that app to hold the export_to_git function.