List all the repositories where the user added as collaborator

Hi,

in my Personal GitHub account have 300 repos).i want to delete one particular user from all my private repositories where i added that user as a collaborator.Is it possible to identity all the private repositories where the user have access by using API?Please help me

1 Like

Hello @srudhin-test and welcome to the community.

The closest I was able to come to what you’re asking for is this GraphQL query:

{
  viewer {
    repositories(affiliations: OWNER, first: 100) {
      nodes {
        nameWithOwner
        collaborators(first: 100, query: "octocat") {
          nodes {
            login
          }
        }
      }
    }
  }
}

It won’t return only the repositories where the user is the collaborator, but it will allow you to easily filter out all the repositories where viewer.repositories.nodes.collaborators.nodes is either null or an empty list. Then all you’ll be left with is the repositories where the particular user you’re looking for is a collaborator.

I hope that helps!

@lee-dohm Thank you for the support.Let me try

1 Like