code: def init(ctx, client, directory, name, force, use_external_storage):
      
      if not client.use_external_storage:
          use_external_storage = False
  
      ctx.obj = client = attr.evolve(
          client,
          path=directory,
          use_external_storage=use_external_storage,
      )
  
      msg = 'Initialized empty project in {path}'
      branch_name = None
  
      stack = contextlib.ExitStack()
  
      if force and client.repo:
          msg = 'Initialized project in {path} (branch {branch_name})'
          merge_args = ['--no-ff', '-s', 'recursive', '-X', 'ours']
  
          try:
              commit = client.find_previous_commit(
                  str(client.renku_metadata_path),
              )
              branch_name = 'renku/init/' + str(commit)
          except KeyError:
              from git import NULL_TREE
              commit = NULL_TREE
              branch_name = 'renku/init/root'
              merge_args.append('--allow-unrelated-histories')
  
          ctx.obj = client = stack.enter_context(
              client.worktree(
                  branch_name=branch_name,
                  commit=commit,
                  merge_args=merge_args,
              )
          )
  
      try:
          with client.lock:
              path = client.init_repository(name=name, force=force)
      except FileExistsError:
          raise click.UsageError(
              'Renku repository is not empty. '
              'Please use --force flag to use the directory as Renku '
              'repository.'
          )
  
      stack.enter_context(client.commit())
  
      with stack:
          # Install Git hooks.
          from .githooks import install
          ctx.invoke(install, force=force)
  
          # Create all necessary template files.
          from .runner import template
          ctx.invoke(template, force=force)
  
      click.echo(msg.format(path=path, branch_name=branch_name))
docs: Initialize a project.