Git add try catch algorithm