Refactored git helper function