def cmd_graft(args):

    branch = fuzzy_match_branch(args.get(0))
    into_branch = args.get(1)

    if not branch:
        print('Please specify a branch to graft:')
        display_available_branches()
        sys.exit()

    if not into_branch:
        into_branch = get_current_branch_name()
    else:
        into_branch = fuzzy_match_branch(into_branch)

    branch_names = get_branch_names(local=True, remote_branches=False)
    remote_branch_names = get_branch_names(local=False, remote_branches=True)

    if branch not in branch_names:
        print("{0} doesn't exist. Use a branch that does.".format(
            colored.yellow(branch)))
        sys.exit(1)

    if branch in remote_branch_names:
        print("{0} is published. To graft it, unpublish it first.".format(
            colored.yellow(branch)))
        sys.exit(1)

    if into_branch not in branch_names:
        print("{0} doesn't exist. Use a branch that does.".format(
            colored.yellow(into_branch)))
        sys.exit(1)

    # Go to new branch.
    switch_to(into_branch)

    status_log(graft_branch, 'Grafting {0} into {1}.'.format(
        colored.yellow(branch), colored.yellow(into_branch)), branch)
Merges an unpublished branch into the given branch, then deletes it.
dataset/ETHPy150Open kennethreitz/legit/legit/cli.py/cmd_graft