Try to undo git commands if they fail to restore previous workspace state.