Move the copyRepository function into gitlib