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 cd
s into the cloned directory.
ℹ️ Tip: See also newrepo
. It creates git repositories into a pre-determined directory structure, and then cd
s 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 install
Finalize with the steps below, depending on the shell you use.
Add the following to your .bashrc
:
source <path to cloned dir>/clonerepo_bash
ln -s <path to cloned dir>/clone.fish ~/.config/fish/functions/clone.fish
-
Install
clonerepo
as shown above. -
We need to tell
clonerepo
where it should store repositories.
mkdir -p ~/.config/clonerepo
Replace directory $HOME/git
below with your preferred directory for keeping repositories:
echo "gitDir: $HOME/git" > ~/.config/clonerepo/config.yaml
Now 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 yourgitDir
to 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