Search code examples
gitgithubpermissionsgitlabpush

How to check remote GIT repository permission without commit/add any files or modify any files


I'm trying to find remote GIT repository permission without any file changes. I have tried below command,

"git push --dry-run"

its shows, everything-up-to-date.

The problem is I have cloned my remote repository after that I removed all my permission in remote git repository I want to know the remote repository permission before any local changes I made.


Solution

  • You can at least check if the remote repo is still remotely readable with git ls-remote

    From any folder in your local machine, type git ls-remote /url/remote/repo.

    But for any more advance permission check, you would need to go to the remote server hosting that repo.

    Or at list query that server, listing the members for a given project.
    See GitLab API "List all members of a group or project".
    Each member has access_level which will give a fined-grained permission.

    10 => Guest access
    20 => Reporter access
    30 => Developer access
    40 => Maintainer access
    50 => Owner access # Only valid for groups
    

    Note that GitLab 15.1 (June 2022) adds:

    API includes additional detail about who added members

    The members API now returns more information about who added a user to a project or group in the new created_by field.

    Thank you Rémy Jacquin for your contribution!

    See Documentation and Issue.