Mounting Git configuration

The user.name and user.email fields will be set automatically to the gitconfig content from a git provider, connected to Che by a Git-provider access token or a token generated via OAuth, if username and email are set on the provider’s user profile page.

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: <gitconfig content> (2)
    1 A user namespace. Visit https://<che_fqdn>/api/kubernetes/namespace to get your Che user namespace as name.
    2 The content of your gitconfig file content.
  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.