Changed foreach loops to linq in GitPreparer (code review recommendation)