All Projects → gabrie30 → Ghorg

gabrie30 / Ghorg

Licence: apache-2.0
Quickly clone an entire org/users repositories into one directory - Supports GitHub, GitLab, Bitbucket, and more

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Ghorg

Generic Webhook Trigger Plugin
Can receive any HTTP request, extract any values from JSON or XML and trigger a job with those values available as variables. Works with GitHub, GitLab, Bitbucket, Jira and many more.
Stars: ✭ 287 (-23.87%)
Mutual labels:  gitlab, bitbucket
vpr
VPR is a CLI that helps you to quickly manage your project in GitHub/GitLab/Bitbucket
Stars: ✭ 17 (-95.49%)
Mutual labels:  gitlab, bitbucket
feater
Tool for rapid deployment of selected features of your web application to isolated testing or demo environments.
Stars: ✭ 27 (-92.84%)
Mutual labels:  gitlab, bitbucket
gitcolombo
🧬 Extract and analyze contributors info from git repos
Stars: ✭ 55 (-85.41%)
Mutual labels:  gitlab, bitbucket
Github Updater
This WP plugin will update GitHub, Bitbucket, GitLab, and Gitea hosted plugins and themes
Stars: ✭ 2,893 (+667.37%)
Mutual labels:  gitlab, bitbucket
git-the-lines
A Discord bot that prints out the lines referenced in a GitHub, GitLab, or BitBucket snippet link
Stars: ✭ 37 (-90.19%)
Mutual labels:  gitlab, bitbucket
github-templates
Good templates for the issue, pull request, and contributing templates on GitHub, GitLab, and Bitbucket.
Stars: ✭ 65 (-82.76%)
Mutual labels:  gitlab, bitbucket
Git Auto Deploy
Deploy your GitHub, GitLab or Bitbucket projects automatically on Git push events or web hooks
Stars: ✭ 251 (-33.42%)
Mutual labels:  gitlab, bitbucket
snk.dev-assistant
Assistant for code development with advanced machine learning features
Stars: ✭ 14 (-96.29%)
Mutual labels:  gitlab, bitbucket
go-scm
Package scm provides a unified interface to multiple source code management systems.
Stars: ✭ 117 (-68.97%)
Mutual labels:  gitlab, bitbucket
10-days-of-git-and-github
asabeneh.github.io/10-days-of-git-and-github/
Stars: ✭ 786 (+108.49%)
Mutual labels:  gitlab, bitbucket
Oauth
🔗 OAuth 2.0 implementation for various providers in one place.
Stars: ✭ 336 (-10.88%)
Mutual labels:  gitlab, bitbucket
playwright-ci
☁️ Set up Playwright in CI
Stars: ✭ 27 (-92.84%)
Mutual labels:  gitlab, bitbucket
froggit-go
Froggit-Go is a universal Go library, allowing to perform actions on VCS providers.
Stars: ✭ 19 (-94.96%)
Mutual labels:  gitlab, bitbucket
Gitlabber
Gitlabber - clones or pulls entire groups tree from gitlab
Stars: ✭ 176 (-53.32%)
Mutual labels:  clone, gitlab
pm2-githook
receive webhook from github/gitlab and ask pm2 to reload the application for you
Stars: ✭ 39 (-89.66%)
Mutual labels:  gitlab, bitbucket
Git Open
Type `git open` to open the GitHub page or website for a repository in your browser.
Stars: ✭ 2,694 (+614.59%)
Mutual labels:  gitlab, bitbucket
Git Link
Emacs package to get the GitHub/Bitbucket/GitLab/... URL for a buffer location
Stars: ✭ 239 (-36.6%)
Mutual labels:  gitlab, bitbucket
myyearwithgit
代码仓库年终总结报告。
Stars: ✭ 176 (-53.32%)
Mutual labels:  gitlab, bitbucket
Skyhook
Parses webhooks and forwards them in the proper format to Discord.
Stars: ✭ 263 (-30.24%)
Mutual labels:  gitlab, bitbucket

ghorg

Go Report Card GoDoc Mentioned in Awesome Go License

ghorg allows you to quickly clone all of an orgs, or users repos into a single directory. This can be useful in many situations including

  1. Searching an orgs/users codebase with ack, silver searcher, grep etc..
  2. Bash scripting
  3. Creating backups
  4. Onboarding
  5. Performing Audits

When running ghorg a second time, all local changes in your *_ghorg directory will be overwritten by whats on GitHub. If you are working out of this directory, make sure you rename it before running a second time otherwise all of your changes will be lost.

ghorg cli example

Supported Providers

  • GitHub
  • GitLab
  • Bitbucket
  • Gitea

The terminology used in ghorg is that of GitHub, mainly orgs/repos. GitLab and BitBucket use different terminology. There is a handy chart thanks to GitLab that translates terminology here

Install

Homebrew

optional

$ brew update
$ brew upgrade git

required

$ brew install gabrie30/utils/ghorg
$ mkdir -p $HOME/.config/ghorg
$ curl https://raw.githubusercontent.com/gabrie30/ghorg/master/sample-conf.yaml > $HOME/.config/ghorg/conf.yaml
$ vi $HOME/.config/ghorg/conf.yaml # (optional but recommended)

Golang

# ensure $HOME/go/bin is in your path ($ echo $PATH | grep $HOME/go/bin)

# if using go 1.16+ locally
go install github.com/gabrie30/[email protected]

# older go versions can run
$ go get github.com/gabrie30/ghorg

$ mkdir -p $HOME/.config/ghorg
$ curl https://raw.githubusercontent.com/gabrie30/ghorg/master/sample-conf.yaml > $HOME/.config/ghorg/conf.yaml
$ vi $HOME/.config/ghorg/conf.yaml # (optional but recommended)

Use

# note: to view/set all available flags/features see sample-conf.yaml
# note: for examples see ./examples
$ ghorg clone someorg
$ ghorg clone someorg --concurrency=50 --token=bGVhdmUgYSBjb21tZW50IG9uIGlzc3VlIDY2
$ ghorg clone someuser --clone-type=user --protocol=ssh --branch=develop --color=off
$ ghorg clone gitlab-group --scm=gitlab --base-url=https://gitlab.internal.yourcompany.com --preserve-dir
$ ghorg clone gitlab-group/gitlab-subgroup --scm=gitlab --base-url=https://gitlab.internal.yourcompany.com
$ ghorg clone --help
# view cloned resources
$ ghorg ls
$ ghorg ls someorg

Setup and Configuration

Note: if you are running into issues, read the troubleshooting and known issues section below

Configuration for each clone can be set in two ways. The first is in $HOME/.config/ghorg/conf.yaml. This file should be created from the sample-conf.yaml by copying into $HOME/.config/ghorg/conf.yaml. The second method of configuration is setting flags via the cli, run $ ghorg clone --help for a list of flags. A flag set on the command line will overwrite any setting in the conf.yaml

github setup

  1. Create Personal Access Token with all repo scopes. Update GHORG_GITHUB_TOKEN in your ghorg/conf.yaml, as a cli flag, or add to your osx keychain.

gitlab setup

  1. Create Personal Access Token with the read_api scope (or api for self-managed GitLab older than 12.10). This token can be added to your ghorg/conf.yaml, as a cli flag, or your osx keychain.
  2. Update the GitLab Specific config in your ghorg/conf.yaml or via cli flags
  3. Update GHORG_SCM_TYPE to gitlab in your ghorg/conf.yaml or via cli flags
  4. See examples/gitlab.md on how to run

gitea setup

  1. Create Access Token (Settings -> Applications -> Generate Token)
  2. Update GHORG_GITEA_TOKEN in your ghorg/conf.yaml or use the (--token, -t) flag.
  3. Update GHORG_SCM_TYPE to gitea in your ghorg/conf.yaml or via cli flags

bitbucket setup

  1. To configure with bitbucket you will need to create a new app password and update your $HOME/.config/ghorg/conf.yaml here or use the (--token, -t) and (--bitbucket-username) flags.
  2. Update SCM type to bitbucket in your ghorg/conf.yaml or via cli flags

osx default github/gitlab token used

NOTE: cloning via https rather than ssh is the ghorg default, this is because a token must be present to retreive the list of repos. However, if you run into trouble cloning via https and genearlly clone via ssh, try switching --protocol ssh

$ security find-internet-password -s github.com  | grep "acct" | awk -F\" '{ print $4 }'
$ security find-internet-password -s gitlab.com  | grep "acct" | awk -F\" '{ print $4 }'

It's recommended to store github/gitlab tokens in the osxkeychain, if this command returns anything other than your token see Troubleshooting section below. However, you can always add your token to the $HOME/.config/ghorg/conf.yaml or use the (--token, -t) flags.

Ignoring Repos

  • To ignore any archived repos while cloning use the --skip-archived flag (not bitbucket)

  • To ignore specific repos create a ghorgignore file inside $HOME/.config/ghorg. Each line in this file is considered a substring and will be compared against each repos clone url. If the clone url contains a substring in the ghorgignore it will be excluded from cloning. To prevent accidentally excluding a repo, you should make each line as specific as possible, eg. https://github.com/gabrie30/ghorg.git or [email protected]:gabrie30/ghorg.git depending on how you clone.

    # Create ghorgignore
    touch $HOME/.config/ghorg/ghorgignore
    
    # update file
    vi $HOME/.config/ghorg/ghorgignore
    

Known issues

  • When cloning if you see something like Username for 'https://gitlab.com': and the run won't finish. Make sure your token is in the osxkeychain, see the troubleshooting section for how to set this up. If this does not work or you are not on mac try cloning via ssh (--protocol=ssh). If this still does not resolve your issue you will need to update your git configs to match below, be sure to update the gitlab.mydomain.com portion

    git config --global url."[email protected]:".insteadOf http://gitlab.mydomain.com/
    git config --global url."git://".insteadOf https://
    
  • If you are cloning a large org you may see Error: open /dev/null: too many open files which means you need to increase your ulimits, there are lots of docs online for this. For mac the quick and dirty is below

    # reset the soft and hard file limit boundaries
    $ sudo launchctl limit maxfiles 65536 200000
    
    # actually now set the ulimit boundary
    $ ulimit -n 20000
    

    Another solution is to decrease the number of concurrent clones. Use the --concurrency flag to set to lower than 25 (the default)

Troubleshooting

  • If the security command does not return your token, follow this GitHub Documentation. For GitHub tokens you will need to set your token as your username and set nothing as the password when prompted. For GitLab you will need to set your token for both the username and password when prompted. This will correctly store your credentials in the keychain. If you are still having problems see this StackOverflow Post
  • If your GitHub account is behind 2fa follow this Github Documentation
  • GitHub Personal Access Token only finding public repos - Give your token all the repo permissions
  • Make sure your $ git --version is >= 2.19.0

Updating brew tap

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].