|
| 1 | +(cli-import)= |
| 2 | + |
| 3 | +# vcspull import |
| 4 | + |
| 5 | +The `vcspull import` command registers existing repositories with your vcspull |
| 6 | +configuration. You can either provide a single repository name and URL or scan |
| 7 | +directories for Git repositories that already live on disk. |
| 8 | + |
| 9 | +## Command |
| 10 | + |
| 11 | +```{eval-rst} |
| 12 | +.. argparse:: |
| 13 | + :module: vcspull.cli |
| 14 | + :func: create_parser |
| 15 | + :prog: vcspull |
| 16 | + :path: import |
| 17 | + :nodescription: |
| 18 | +``` |
| 19 | + |
| 20 | +## Manual import |
| 21 | + |
| 22 | +Provide a repository name and remote URL to append an entry to your |
| 23 | +configuration. Use `--path` when you already have a working tree on disk so the |
| 24 | +configured base directory matches its location. Override the inferred base |
| 25 | +directory with `--dir` when you need a specific configuration key. |
| 26 | + |
| 27 | +```console |
| 28 | +$ vcspull import my-lib https://github.com/example/my-lib.git --path ~/code/my-lib |
| 29 | +``` |
| 30 | + |
| 31 | +With no `-c/--config` flag vcspull looks for the first YAML configuration file |
| 32 | +under `~/.config/vcspull/` or the current working directory. When none exist a |
| 33 | +new `.vcspull.yaml` is created next to where you run the command. |
| 34 | + |
| 35 | +## Filesystem scanning |
| 36 | + |
| 37 | +`vcspull import --scan` discovers Git repositories that already exist on disk |
| 38 | +and writes them to your configuration. The command prompts before adding each |
| 39 | +repository, showing the inferred name, directory key, and origin URL (when |
| 40 | +available). |
| 41 | + |
| 42 | +```console |
| 43 | +$ vcspull import --scan ~/code --recursive |
| 44 | +? Add ~/code/vcspull (dir: ~/code/)? [y/N]: y |
| 45 | +? Add ~/code/libvcs (dir: ~/code/)? [y/N]: y |
| 46 | +``` |
| 47 | + |
| 48 | +- `--recursive`/`-r` searches nested directories. |
| 49 | +- `--base-dir-key` forces all discovered repositories to use the same base |
| 50 | + directory key, overriding the automatically expanded directory. |
| 51 | +- `--yes`/`-y` accepts every suggestion, which is useful for unattended |
| 52 | + migrations. |
| 53 | + |
| 54 | +When vcspull detects a Git remote named `origin` it records the remote URL in |
| 55 | +the configuration. Repositories without a remote are still added, allowing you |
| 56 | +to fill the `repo` key later. |
| 57 | + |
| 58 | +## Choosing configuration files |
| 59 | + |
| 60 | +Pass `-c/--config` to import into a specific YAML file: |
| 61 | + |
| 62 | +```console |
| 63 | +$ vcspull import --scan ~/company --recursive --config ~/company/.vcspull.yaml |
| 64 | +``` |
| 65 | + |
| 66 | +Use `--all` with the [`vcspull fmt`](cli-fmt) command after a large scan to keep |
| 67 | +configuration entries sorted and normalized. |
0 commit comments