clonerepo removes the hazzle of having to use cd to the preferred directory when cloning from GitHub.
It clones github repositores into a pre-determined directory structure, and then cds into the cloned directory.
ℹ️ Tip: See also newrepo. It creates git repositories into a pre-determined directory structure, and then cds into the directory containing the repository.
Example
/tmp $ . clonerepo https://github.com/yngvark/newrepo.git
Cloning into directory: /home/myself/git/yngvark/newrepo
Cloning into 'newrepo'...
remote: Enumerating objects: 26, done.
remote: Counting objects: 100% (26/26), done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 26 (delta 7), reused 23 (delta 4), pack-reused 0
Receiving objects: 100% (26/26), 9.02 KiB | 9.02 MiB/s, done.
Resolving deltas: 100% (7/7), done.
~/git/newrepo (main) $ Notice that clonerepo changed the current directory (where the parent path is configurable).
git clone https://github.com/yngvark/clonerepo.git
cd clonerepo
go installFinalize with the steps below, depending on the shell you use.
Add the following to your .bashrc:
source <path to cloned dir>/clonerepo_bashln -s <path to cloned dir>/clone.fish ~/.config/fish/functions/clone.fish -
Install
clonerepoas shown above. -
We need to tell
clonerepowhere it should store repositories.
mkdir -p ~/.config/clonerepoReplace directory $HOME/git below with your preferred directory for keeping repositories:
echo "gitDir: $HOME/git" > ~/.config/clonerepo/config.yamlNow you can try cloning a directory:
clone https://github.com/yngvark/clonerepo- Notice how the current directory changed to
$HOME/git/clonerepo- or whatever you set yourgitDirto in the configuration above.
- Remove binary
rm $GOBIN/clonerepo- Remove the Bash or Fish specific parts added under Install
$ clone -h
usage: clonerepo [-h] [-t] repoUri
git clones a repo URI to the appropriate directory. Tip: use ". clonerepo <args>"
to change directory to cloned directory.
positional arguments:
repoUri URI of the repo to clone
optional arguments:
-h, --help show this help message and exit
-t, --temp Clone the repository in a temporary directory