How To: Switch Git Context from OAuth to PAT


Currently, the git context is set to OAuth but would like to use Personal Access Token (PAT) instead.


  1. Use the Codefresh CLI to get all available contexts:
    codefresh get contexts

  2. In the output, find the name of the git context you want to update.
  3. Use the Codefresh CLI to get the YAML version of the git context and save it to a file:
    codefresh get context [git-context-name] --decrypt -o yaml > gitContext.yaml
  4. Open the file and switch the YAML to the following. The section that needs to be changed is mainly the section.

     apiVersion: v1  
     kind: context
       default: false
       system: false
       name: GITCONTEXT
     type: git.github
       type: git.github
         sharingPolicy: AllUsersInAccount
           type: basic
           password: ghp_xxxxxxxxxxxxxxxxxxxxxxxxx
         behindFirewall: false
         sshClone: false
         secretStoreReferences: []
  5. Save the File
  6. Use the Codefresh CLI to patch the git context
    codefresh patch context -f gitContext.yaml
  7. Now all pipelines and triggers will use PAT instead of OAuth.