· 2 min read

Fixing Second Repo Permissions Issue in GitHub Codespaces

During a recent demo, I ran into a repository permissions issue in GitHub Codespaces after cloning another repo and trying to commit code—this didn’t work.

During a recent demo, I ran into a repository permissions issue in GitHub Codespaces after cloning another repo and trying to commit code—this didn’t work.

Introduction

On a recent demo, I had encountered a repository permissions issue when using GitHub Codespaces after cloning another repo within the same codespace and trying to commit code in the newly cloned repo - which didnt work and complained of a permissions issue.

Hauston, we have git a problem

This is a leasons learn’t post, occassionally things go wrong and want to show how to fix this either for my future self, or anyone encountering the same issue.

The demo, was to build a declarative agent in Agent Repo and submit to another repository as a Community Submission Repo like this:

AI Generated visual of the setup I was trying to acheive

Apparently, you cannot just clone the repo, and use the current token/credentials codespace is using. Even, applying repo permissions to the container did not resolve my issue.

The Answer

To resolve this:

  • Create a personal token in GitHub
  • Navigate to the repo hosting the codespace
  • Use settings to create a new repository secret under Settings > Secrets and Variables > Codespaces secrets

Add Secret to repository hosting the code space

  • Re-clone the other (community) repository with git clone https://USERNAME:$YOUR-SECRET-VARAIBLE-NAME@github.com/OWNER/REPO

Cloning the repo

  • Repeat the exercise, e.g. copy the changes from one repo to another.

Conclusion

Occasionally things happen, so note to future self, please check permissions lol before a demo to 150+ people. Hope this helps folks too 😊

Resources

The following resource could be useful for you to learn further:

Enjoy!

Share:
Back to Blog