3.6 KiB
GitLab Examples
Note: all command line arguments can be permanently set in your
$HOME/.config/ghorg/conf.yamlfor more information see the configuration section of the README.md.
To view all additional flags see the sample-conf.yaml or use ghorg clone --help
Things to know
-
There are differences in how ghorg works with GitLab on hosted instances vs GitLab cloud. Please make sure to follow the correct section below.
-
With GitLab, if ghorg detects repo naming collisions with repos being cloned from different groups/subgroups, ghorg will automatically append the group/subgroup path to the repo name. You will be notified in the output if this occurs.
-
For all versions of GitLab you can clone groups or sub groups individually
Hosted GitLab Instances
Cloning All Groups
Note: "all-groups" only works on hosted GitLab instances running 13.0.1 or greater
Note: You must set
--base-urlwhich is the url to your instance. If your instance requires an insecure connection you can use the--insecure-gitlab-clientflag
-
Clone all groups preserving the directory structure of subgroups
ghorg clone all-groups --base-url=https://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX --preserve-dir -
Clone all groups on an insecure instance preserving the directory structure of subgroups
ghorg clone all-groups --base-url=http://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX --preserve-dir --insecure-gitlab-client
Cloning Specific Groups
-
Clone a single group, preserving the directory structure of any subgroups within that group
ghorg clone <gitlab_group> --base-url=https://<your.instance.gitlab.com> --scm=gitlab --preserve-dir -
Clone only a subgroup
ghorg clone <gitlab_group>/<gitlab_sub_group> --base-url=https://<your.instance.gitlab.com> --scm=gitlab -
clone all repos that are prefixed with "frontend" into a folder called "design_only"
ghorg clone <gitlab_group> --base-url=https://<your.instance.gitlab.com> --scm=gitlab --match-regex=^frontend --output-dir=design_only
Cloning a Specific Users Repos
-
Clone a user on a hosted gitlab instance using a token for auth
ghorg clone <gitlab_username> --clone-type=user --base-url=https://<your.instance.gitlab.com> --scm=gitlab --token=bGVhdmUgYSBjb21tZW50IG9uIGlzc3VlIDY2
Cloning All Users Repos
Note: "all-users" only works on hosted GitLab instances running 13.0.1 or greater
Note: You must set
--base-urlwhich is the url to your instance. If your instance requires an insecure connection you can use the--insecure-gitlab-clientflag
-
Clone all users repos into a directory called all-users-repos
ghorg clone all-users --base-url=https://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX --clone-type=user --output-dir=all-users-repos -
Clone all users repos on an insecure instance
ghorg clone all-users --base-url=http://<your.instance.gitlab.com> --scm=gitlab --token=XXXXXX --clone-type=user --insecure-gitlab-client
Cloud GitLab Orgs
Examples below use the gitlab-examples GitLab cloud organization https://gitlab.com/gitlab-examples
-
clone all groups, preserving the directory structure of subgroups
ghorg clone gitlab-examples --scm=gitlab --token=XXXXXX --preserve-dir -
clone only a subgroup
ghorg clone gitlab-examples/wayne-enterprises --scm=gitlab --token=XXXXXX