Move create_branch into a library file