@unbare_repo
    def move(self, module_path, configuration=True, module=True):
        """Move the submodule to a another module path. This involves physically moving
        the repository at our current path, changing the configuration, as well as
        adjusting our index entry accordingly.

        :param module_path: the path to which to move our module in the parent repostory's working tree,
            given as repository-relative or absolute path. Intermediate directories will be created
            accordingly. If the path already exists, it must be empty.
            Trailing (back)slashes are removed automatically
        :param configuration: if True, the configuration will be adjusted to let
            the submodule point to the given path.
        :param module: if True, the repository managed by this submodule
            will be moved as well. If False, we don't move the submodule's checkout, which may leave
            the parent repository in an inconsistent state.
        :return: self
        :raise ValueError: if the module path existed and was not empty, or was a file
        :note: Currently the method is not atomic, and it could leave the repository
            in an inconsistent state if a sub-step fails for some reason
        """
        if module + configuration < 1:
            raise ValueError("You must specify to move at least the module or the configuration of the submodule")
        # END handle input

        module_checkout_path = self._to_relative_path(self.repo, module_path)

        # VERIFY DESTINATION
        if module_checkout_path == self.path:
            return self
        # END handle no change

        module_checkout_abspath = join_path_native(self.repo.working_tree_dir, module_checkout_path)
        if os.path.isfile(module_checkout_abspath):
            raise ValueError("Cannot move repository onto a file: %s" % module_checkout_abspath)
        # END handle target files

        index = self.repo.index
        tekey = index.entry_key(module_checkout_path, 0)
        # if the target item already exists, fail
        if configuration and tekey in index.entries:
            raise ValueError("Index entry for target path did already exist")
        # END handle index key already there

        # remove existing destination
        if module:
            if os.path.exists(module_checkout_abspath):
                if len(os.listdir(module_checkout_abspath)):
                    raise ValueError("Destination module directory was not empty")
                # END handle non-emptiness

                if os.path.islink(module_checkout_abspath):
                    os.remove(module_checkout_abspath)
                else:
                    os.rmdir(module_checkout_abspath)
                # END handle link
            else:
                # recreate parent directories
                # NOTE: renames() does that now
                pass
            # END handle existence
        # END handle module

        # move the module into place if possible
        cur_path = self.abspath
        renamed_module = False
        if module and os.path.exists(cur_path):
            os.renames(cur_path, module_checkout_abspath)
            renamed_module = True

            if os.path.isfile(os.path.join(module_checkout_abspath, '.git')):
                module_abspath = self._module_abspath(self.repo, self.path, self.name)
                self._write_git_file_and_module_config(module_checkout_abspath, module_abspath)
            # end handle git file rewrite
        # END move physical module

        # rename the index entry - have to manipulate the index directly as
        # git-mv cannot be used on submodules ... yeah
        previous_sm_path = self.path
        try:
            if configuration:
                try:
                    ekey = index.entry_key(self.path, 0)
                    entry = index.entries[ekey]
                    del(index.entries[ekey])
                    nentry = git.IndexEntry(entry[:3] + (module_checkout_path,) + entry[4:])
                    index.entries[tekey] = nentry
                except __HOLE__:
                    raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path))
                # END handle submodule doesn't exist

                # update configuration
                writer = self.config_writer(index=index)        # auto-write
                writer.set_value('path', module_checkout_path)
                self.path = module_checkout_path
                writer.release()
                del(writer)
            # END handle configuration flag
        except Exception:
            if renamed_module:
                os.renames(module_checkout_abspath, cur_path)
            # END undo module renaming
            raise
        # END handle undo rename

        # Auto-rename submodule if it's name was 'default', that is, the checkout directory
        if previous_sm_path == self.name:
            self.rename(module_checkout_path)
        # end

        return self
dataset/ETHPy150Open gitpython-developers/GitPython/git/objects/submodule/base.py/Submodule.move