Changing directory before deleting refs