|
1 | | -# `> gitclone` |
| 1 | +``` |
| 2 | +__ _ __ __ |
| 3 | +\ \ ____ _(_) /______/ /___ ____ ___ |
| 4 | + \ \ / __ `/ / __/ ___/ / __ \/ __ \/ _ \ |
| 5 | + / / / /_/ / / /_/ /__/ / /_/ / / / / __/ |
| 6 | +/_/ \__, /_/\__/\___/_/\____/_/ /_/\___/ |
| 7 | + /____/ |
| 8 | +``` |
2 | 9 | cli tool to clone git repositories in the folder structure implied by the repository url |
3 | 10 |
|
4 | 11 | ## Concept |
|
37 | 44 | ----------------- |
38 | 45 | The benefits become even more apparent, when we have to work with multiple GitHub (Enterprise) or GitLab instances. Even more so because GitLab allows the use of nested groups. |
39 | 46 | ## Installation |
| 47 | +### Pre-built binaries |
| 48 | +pre-built binaries are available for Linux, MacOS and Windows. |
| 49 | +#### Linux |
| 50 | +``` |
| 51 | +sudo wget https://github.com/mxcd/gitclone/releases/latest/download/gitclone-linux-amd64 -O /usr/local/bin/gitclone && sudo chmod +x /usr/local/bin/gitclone |
| 52 | +``` |
| 53 | +#### MacOS 11 and newer (amd64) |
| 54 | +``` |
| 55 | +sudo wget https://github.com/mxcd/gitclone/releases/latest/download/gitclone-macos-11-amd64 -O /usr/local/bin/gitclone && sudo chmod +x /usr/local/bin/gitclone |
| 56 | +``` |
| 57 | +#### MacOS 11 and newer (apple silicon) |
| 58 | +``` |
| 59 | +sudo wget https://github.com/mxcd/gitclone/releases/latest/download/gitclone-macos-11-apple -O /usr/local/bin/gitclone && sudo chmod +x /usr/local/bin/gitclone |
| 60 | +``` |
| 61 | +#### MacOS 10.15 (amd64) |
| 62 | +``` |
| 63 | +sudo wget https://github.com/mxcd/gitclone/releases/latest/download/gitclone-macos-10.15-amd64 -O /usr/local/bin/gitclone && sudo chmod +x /usr/local/bin/gitclone |
| 64 | +``` |
| 65 | +#### Windows |
| 66 | +Go to the latest release page and download your binary: |
| 67 | +https://github.com/mxcd/gitclone/releases/latest |
| 68 | +Place it in `C:\Windows\System32\gitclone.exe` |
| 69 | + |
| 70 | +### Build from source |
| 71 | +#### Prequisites |
| 72 | + |
| 73 | +Make sure you have the latest version of rust installed: |
| 74 | +https://www.rust-lang.org/tools/install |
| 75 | +#### Clone & Build |
| 76 | +``` |
| 77 | +git clone https://github.com/mxcd/gitclone |
| 78 | +cd gitclone |
| 79 | +cargo build --release |
| 80 | +sudo cp target/release/gitclone /usr/local/bin/gitclone |
| 81 | +sudo chmod u+x /usr/local/bin/gitclone |
| 82 | +``` |
| 83 | + |
40 | 84 |
|
41 | 85 | ## Usage |
| 86 | +### Initialization |
42 | 87 | Firstly, the root directory of the git provider needs to be initialized. |
| 88 | +Create a directory that will act as the root of your git provider. |
| 89 | +We encourage you to name the directory after the provider (e.g. `./github.com`) |
43 | 90 | The base URL of the git provider will be prompted. |
44 | 91 | ``` |
45 | | -$> gitclone init |
46 | | - git provider base url: |
47 | | - github.com |
48 | | - gitclone provider root registered |
49 | | -$> |
| 92 | +$ mkdir github.com |
| 93 | +$ cd github.com |
| 94 | +$ gitclone init |
| 95 | +__ _ __ __ |
| 96 | +\ \ ____ _(_) /______/ /___ ____ ___ |
| 97 | + \ \ / __ `/ / __/ ___/ / __ \/ __ \/ _ \ |
| 98 | + / / / /_/ / / /_/ /__/ / /_/ / / / / __/ |
| 99 | +/_/ \__, /_/\__/\___/_/\____/_/ /_/\___/ |
| 100 | + /____/ |
| 101 | +
|
| 102 | +=> Initializing gitclone root |
| 103 | +
|
| 104 | +please enter git provider base url including protocol |
| 105 | +for https connections: e.g. https://github.com |
| 106 | +for ssh connections: e.g. ssh://git@github.com |
| 107 | +
|
| 108 | +git provider base url: |
| 109 | +https://github.com |
| 110 | +
|
| 111 | +input http(s) basic auth credentials. leave blank if not required. |
| 112 | +WARNING: credentials will be stored in plain text in the root file. If you are uncomfortable with this please consider using ssh instead. |
| 113 | +
|
| 114 | +BasicAuth credentials: username:access-token-or-api-key |
| 115 | +
|
| 116 | +$ |
50 | 117 | ``` |
| 118 | +This will create a .gitclone_root.yml file in the directory marking it as root directory for the git provider. |
51 | 119 |
|
| 120 | +### Cloning |
52 | 121 | ``` |
53 | 122 | gitclone <relative path> |
54 | 123 | ``` |
| 124 | +This will clone the repository with respect to the relative path you have to the root directory. |
| 125 | + |
| 126 | +### Examples |
| 127 | +#### Cloning from the root directory |
| 128 | +``` |
| 129 | +$ pwd |
| 130 | +/home/user/github.com |
| 131 | +$ gitclone mxcd/api-template |
| 132 | +``` |
| 133 | +This will create the `mxcd` directory and clone the repository `api-template` into it. |
| 134 | +#### Cloning from a subdirectory |
| 135 | +``` |
| 136 | +$ pwd |
| 137 | +/home/user/github.com/mxcd |
| 138 | +$ gitclone api-template |
| 139 | +``` |
| 140 | +This will clone the repository `api-template` from `mxcd/api-template` into the current directory since you already are in the `mxcd` directory. |
| 141 | + |
| 142 | +#### Cloning from within nested subdirectories |
| 143 | +``` |
| 144 | +$ pwd |
| 145 | +/home/user/gitlab.com/some/nested/group |
| 146 | +$ gitclone subgroup/my-repo |
| 147 | +``` |
| 148 | +This will clone the repository `my-repo` from `gitlab.com/some/nested/group/subgroup/my-repo` into the `./subgroup/my-repo` directory. |
55 | 149 |
|
56 | | -### Examples |
| 150 | +## License |
| 151 | +Licensed under MIT License |
| 152 | +Copyright (c) 2022 Max Partenfelder |
0 commit comments