Mounting Git configuration

Follow the instructions below to mount a Git config file in a workspace.

Prerequisites
  • You have logged in to the cluster.

Procedure
  1. Prepare a new Kubernetes ConfigMap.

    kind: ConfigMap
    apiVersion: v1
    metadata:
      name: workspace-userdata-gitconfig-configmap
      namespace: <user_namespace> (1)
      labels:
        controller.devfile.io/mount-to-devworkspace: 'true'
        controller.devfile.io/watch-configmap: 'true'
      annotations:
        controller.devfile.io/mount-as: subpath
        controller.devfile.io/mount-path: /etc/
    data:
      gitconfig: "[user] \n  name = <git_user_name> \n  email = <git_user_email>" (2)
    1 A user namespace. Visit https://<che_fqdn>/api/kubernetes/namespace to get your Che user namespace as name.
    2 Your Git user name and email.
  2. Apply the ConfigMap.

    $ kubectl apply -f - <<EOF
    <ConfigMap_prepared_in_step_1>
    EOF
Verification
  1. Start a new workspace by using the URL of a remote Git repository that the Git provider hosts.

  2. Once the workspace is started, open a new terminal in the tools container and run git config --get-regexp user.*. Your Git user name and email should appear in the output.