def move_branch(movebranch, force, verbose):
    '''move oldbranch (or active_branch) to newbranch. update config if needed'''
    repo = _get_repo()
    oldbranch, newbranch = ([repo.active_branch] + movebranch)[-2:]

    if oldbranch not in repo.branches:
        raise GitError('{} does not exist in branches'.format(oldbranch))
    if newbranch in repo.branches and not force:
        raise GitError('{} already exists.  use -M to force overwriting'.format(newbranch))
    if newbranch != oldbranch:
        print('Renaming {} ({}) to {}\n'.format(oldbranch, repo.branches[oldbranch], newbranch))
        repo.add_ref(repo._format_ref_branch(newbranch), repo._format_ref_branch(oldbranch))
        del repo.repo.refs[repo._format_ref_branch(oldbranch)]
        #todo: reflog
    if oldbranch == repo.active_branch:
        repo.active_branch = newbranch
move oldbranch (or active_branch) to newbranch. update config if needed
lib/git/git-branch.py