Code Monkey home page Code Monkey logo

git-beam-it's Introduction

Beam-it: Bulk clone Github Repositories

This bash script will bulk clone Github repositories for a specific user/organisation or team.

The script will automatically configure itself by asking the user to enter some required information in order to be able to communicate with the Github API.

The script has no external dependencies except for jq which is only required to parse the team list.

When running the script for the first time, the user will be prompted to enter his Github username and API personal access token. For more information on API personal access tokens, check this Github tutorial

Repositories Refresh

When cloning, if the repository already exists then the script will perfrom a git pull assuming that the remote is origin and will update the local `master branch

Installation

You can use the script git-beam-it.sh by exporting that into your .bash_profile, .bashrc or .zshrc and then make sure that it is executable with chmod +x git-beam-it.sh. However, the recommended way to use it is by registering it as a git plugin.

The main requirement for git plugins is that the name of the shell script should be git-name where name is the command you want to run after typing git. Our script, beam-it is already configured accordingly.

Now, you only need to put the script in /usr/local/bin or somewhere similar in your $PATH and thats it !

One-liner Installations

Installation with curl:

curl -L -O https://raw.githubusercontent.com/SeedJobs/git-beam-it/master/git-beam-it && sudo mv git-beam-it /usr/local/bin/ && sudo chmod +x /usr/local/bin/git-beam-it

Installation with wget:

sudo wget -P /usr/local/bin https://raw.githubusercontent.com/SeedJobs/git-beam-it/master/git-beam-it && sudo chmod +x /usr/local/bin/git-beam-it

Note: After first setup, you might need to source your .bash_profile, .bashrc or .zshrc in order for the variables export to take effect and not to be prompted again

beam-it

Usage: git beam-it <options>

Options

Argument Name Description Default
-h help show help
-i interactive interactive clone mode. The user will be prompted before cloning each repo false
-d directory specify a directory to clone all the repositories into without a trailing slash e.g. /temp .
-p type specify the types of repos supported by Github you wish to clone down. Supported types: all, owner, public, private, member all
-s ssh clone github repos over ssh and not https (this will use the SSH keys if uploaded to Github and will prevent the password prompt) false
-r regex filter repositories based on this regex
-t team clone only repositories belonging to this specific team id
-o organisation clone only repositories belonging to this specific organisation name

If the paramteres -t and -o have been left empty, then the script will fetch the list of ogranisations and teams for that specific user, the user will then be prompted to enter the organisation name or team id or just skip to fetch all repositories.

beam-it setup

Examples:

# Clone interactively all the private repositories for the user
git beam-it -p private -i

# Clone interactively all the public repos that match the regex .*SeedJobs.* (any repo that contain SeedJobs)
git beam-it -i -r .*SeedJobs.*

# Clone all the public repositores for organisation SeedJobs
git beam-it -p public -o SeedJobs

# Clone all team repos .. first show a prompt of the list of teams and do the clone over SSH into a temp directory at home
git beam-it -d ~/temp -s -t

the paramteres -t and -o are mutually exclusive .. make sure you only execute the command for a specific team or organisation.

beam-it team

beam-it prompts the user to select from his list of teams if no team id was defined

Known Issues

  • Due to limitations in Github API, users cannot specify the type of repos to clone down for teams. This means that all the team repos (public, private) will be cloned down
  • At the moment, there is no way to exclude forks from being cloned down as well :()

git-beam-it's People

Contributors

ahmadassaf avatar zorab47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

git-beam-it's Issues

Repositories with dots in the name fail to resolve correctly

I am running beam-it on Ubuntu 18.04 (Linux Subsystem on Windows), and trying to clone all my repositories after a fresh installation ๐Ÿป
Thanks for the handy tool, hoping to save me some hours ๐Ÿ’š

user@MACHINE:/somepath$ git beam-it
[...]
Since no team or organisation were defined, retreiving all repositories for the user
Retrieving batch: 1 of repositories -->  22  processed so far
Retrieving batch: 2 of repositories -->  22  processed so far
Finished retrieving all repositories with Total:  22
Beaming down all the repositories now ...

Everything looks great ๐Ÿ‘

github.com/dittodhole/dittodhole.github.io.git
Cloning into './dittodhole'...
remote: Counting objects: 2172, done.
remote: Total 2172 (delta 0), reused 0 (delta 0), pack-reused 2172
Receiving objects: 100% (2172/2172), 1.15 MiB | 671.00 KiB/s, done.
Resolving deltas: 100% (1240/1240), done.
Checking connectivity... done.

dittodhole.github.io then resolves to ./dittodhole.

git-beam-it.sh#L185 splits on dots and uses the first segment only:

REPOSITORY_NAME=`echo $(basename $repository) | cut -d"." -f1`

I am not that bash guy, so any help is appreciated :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.