code: def rename(self, new_name):
          
          if self.name == new_name:
              return self
  
          # .git/config
          with self.repo.config_writer() as pw:
              # As we ourselves didn't write anything about submodules into the parent .git/config,
              # we will not require it to exist, and just ignore missing entries.
              if pw.has_section(sm_section(self.name)):
                  pw.rename_section(sm_section(self.name), sm_section(new_name))
  
          # .gitmodules
          with self.config_writer(write=True).config as cw:
              cw.rename_section(sm_section(self.name), sm_section(new_name))
  
          self._name = new_name
  
          # .git/modules
          mod = self.module()
          if mod.has_separate_working_tree():
              destination_module_abspath = self._module_abspath(self.repo, self.path, new_name)
              source_dir = mod.git_dir
              # Let's be sure the submodule name is not so obviously tied to a directory
              if destination_module_abspath.startswith(mod.git_dir):
                  tmp_dir = self._module_abspath(self.repo, self.path, str(uuid.uuid4()))
                  os.renames(source_dir, tmp_dir)
                  source_dir = tmp_dir
              # end handle self-containment
              os.renames(source_dir, destination_module_abspath)
              self._write_git_file_and_module_config(mod.working_tree_dir, destination_module_abspath)
          # end move separate git repository
  
          return self
docs: Rename this submodule
          :note: This method takes care of renaming the submodule in various places, such as
  
              * $parent_git_dir/config
              * $working_tree_dir/.gitmodules
              * (git >=v1.8.0: move submodule repository to new name)
  
          As .gitmodules will be changed, you would need to make a commit afterwards. The changed .gitmodules file
          will already be added to the index
  
          :return: this submodule instance