git
I wrote a short bash script called ghclone
that accepts a github user and repo. It clones the github repository following a particular directory structure. Bob the developer has already installed and configured git
. He has already added a ssh
key to his github account. Bob needs to download source code from multiple online services. He wants to organize the source code by service, and whatever directory structure makes sense under that depending on the service. For instance github repositories should live in this directory structure: ~/Code/github/user/repo
. To clone my Hunt the Wumpus java applet Bob runs
ghclone sbaldasty wumpus-applet
Here is the full ghclone
script in its current form. As always please exercise caution with code that interacts with third party systems, and with code that can potentially modify or delete data.
#!/bin/bash set -e if ! [ $# -eq 2 ]; then echo "Requires 2 parameters." exit 1 fi d=$HOME/Code/github/$1 mkdir -p $d git clone git@github.com:$1/$2.git $d/$2
The script does not clean up any files or directories it created if cloning the repository fails.