22
33# vcspull add
44
5- The ` vcspull add ` command adds a single repository to your vcspull configuration.
6- Provide a repository name and URL, and vcspull will append it to your config file
7- with the appropriate workspace root.
5+ The ` vcspull add ` command registers a repository in your configuration by
6+ pointing vcspull at a checkout on disk. The command inspects the directory,
7+ merges duplicate workspace roots by default, and prompts before writing unless
8+ you pass ` --yes ` .
89
910``` {note}
1011This command replaces the manual import functionality from `vcspull import`.
@@ -24,154 +25,112 @@ For bulk scanning of existing repositories, see {ref}`cli-discover`.
2425
2526## Basic usage
2627
27- Add a repository by name and URL :
28+ Point to an existing checkout to add it under its parent workspace :
2829
2930``` console
30- $ vcspull add flask https://github.com/pallets/flask.git
31- Successfully added 'flask' to ./.vcspull.yaml under './'
31+ $ vcspull add ~ /study/python/pytest-docker
32+ Found new repository to import:
33+ + pytest-docker (https://github.com/avast/pytest-docker)
34+ • workspace: ~/study/python/
35+ ↳ path: ~/study/python/pytest-docker
36+ ? Import this repository? [y/N]: y
37+ Successfully added 'pytest-docker' (git+https://github.com/avast/pytest-docker) to ~/.vcspull.yaml under '~/study/python/'.
3238```
3339
34- By default, the repository is added to the current directory's workspace root (` ./ ` ).
40+ The parent directory (` ~/study/python/ ` in this example) becomes the workspace
41+ root. vcspull shortens paths under ` $HOME ` to ` ~/... ` in its log output so the
42+ preview stays readable.
3543
36- ## Specifying workspace root
44+ ## Overriding detected information
3745
38- Use ` -w/--workspace ` or ` --workspace-root ` to control where the repository will be checked out:
46+ ### Choose a different name
3947
40- ``` console
41- $ vcspull add flask https://github.com/pallets/flask.git -w ~ /code/
42- Successfully added 'flask' to ~/.vcspull.yaml under '~/code/'
43- ```
44-
45- All three flag names work identically:
48+ Override the derived repository name with ` --name ` when the directory name
49+ isn't the label you want stored in the configuration:
4650
4751``` console
48- $ vcspull add django https://github.com/django/django.git --workspace ~ /code/
49- $ vcspull add requests https://github.com/psf/requests.git --workspace-root ~ /code/
52+ $ vcspull add ~ /study/python/pytest-docker --name docker-pytest
5053```
5154
52- ## Custom repository path
55+ ### Override the remote URL
5356
54- Override the inferred path with ` --path ` when the repository already exists on disk:
57+ vcspull reads the Git ` origin ` remote automatically. Supply ` --url ` when you
58+ need to register a different remote or when the checkout does not have one yet:
5559
5660``` console
57- $ vcspull add my-lib https://github.com/example/my-lib.git \
58- --path ~/code/libraries/my-lib
61+ $ vcspull add ~ /study/python/example --url https://github.com/org/example
5962```
6063
61- The ` --path ` flag is useful when:
62- - Migrating existing local repositories
63- - Using non-standard directory layouts
64- - The repository name doesn't match the desired directory name
65-
66- You can also point ` vcspull add ` at an existing checkout. Supplying a path such
67- as ` vcspull add ~/projects/example ` infers the repository name, inspects its
68- ` origin ` remote, and prompts before writing. Add ` --yes ` when you need to skip
69- the confirmation in scripts.
70-
71- ## Choosing configuration files
72-
73- By default, vcspull looks for the first YAML configuration file in:
74- 1 . Current directory (` .vcspull.yaml ` )
75- 2 . Home directory (` ~/.vcspull.yaml ` )
76- 3 . XDG config directory (` ~/.config/vcspull/ ` )
64+ URLs follow [ pip's VCS format] [ pip vcs url ] ; vcspull inserts the ` git+ ` prefix
65+ for HTTPS URLs so the resulting configuration matches ` vcspull fmt ` output.
7766
78- If no config exists, a new ` .vcspull.yaml ` is created in the current directory.
67+ ### Select a workspace explicitly
7968
80- Specify a custom config file with ` -f/--file ` :
69+ The workspace defaults to the checkout's parent directory. Pass
70+ ` --workspace ` /` --workspace-root ` to store the repository under a different
71+ section:
8172
8273``` console
83- $ vcspull add vcspull https://github.com/vcs-python/vcspull.git \
84- -f ~/projects/.vcspull.yaml
74+ $ vcspull add ~ /scratch/tmp-project --workspace ~ /projects/python/
8575```
8676
87- ## Dry run mode
88-
89- Preview changes without modifying your configuration with ` --dry-run ` or ` -n ` :
90-
91- ``` console
92- $ vcspull add flask https://github.com/pallets/flask.git -w ~ /code/ --dry-run
93- Would add 'flask' (https://github.com/pallets/flask.git) to ~/.vcspull.yaml under '~/code/'
94- ```
95-
96- This is useful for:
97- - Verifying the workspace root is correct
98- - Checking which config file will be modified
99- - Testing path inference
100-
101- ## URL formats
102-
103- Repositories use [ pip VCS URL] [ pip vcs url ] format with a scheme prefix:
77+ ## Confirmation and dry runs
10478
105- - Git: ` git+https://github.com/user/repo.git `
106- - Mercurial: ` hg+https://bitbucket.org/user/repo `
107- - Subversion: ` svn+http://svn.example.org/repo/trunk `
108-
109- The URL scheme determines the VCS type. For Git, the ` git+ ` prefix is required.
110-
111- ## Examples
112-
113- Add to default location:
114-
115- ``` console
116- $ vcspull add myproject https://github.com/myuser/myproject.git
117- ```
118-
119- Add to specific workspace:
79+ ` vcspull add ` asks for confirmation before writing. Use ` --yes ` to skip the
80+ prompt in automation, or ` --dry-run ` /` -n ` to preview the changes without
81+ modifying any files:
12082
12183``` console
122- $ vcspull add django-blog https://github.com/example/django-blog.git \
123- -w ~/code/django/
84+ $ vcspull add ~ /study/python/pytest-docker --dry-run
12485```
12586
126- Add with custom path:
87+ Dry runs still show duplicate merge diagnostics so you can see what would
88+ change.
12789
128- ``` console
129- $ vcspull add dotfiles https://github.com/myuser/dotfiles.git \
130- --path ~/.dotfiles
131- ```
90+ ## Choosing configuration files
13291
133- Preview before adding :
92+ vcspull searches for configuration files in this order :
13493
135- ``` console
136- $ vcspull add flask https://github.com/pallets/flask.git \
137- -w ~/code/ --dry-run
138- ```
94+ 1 . ` ./.vcspull.yaml `
95+ 2 . ` ~/.vcspull.yaml `
96+ 3 . ` ~/.config/vcspull/*.yaml `
13997
140- Add to specific config file:
98+ Specify a file explicitly with ` -f/-- file` :
14199
142100``` console
143- $ vcspull add tooling https://github.com/company/tooling.git \
144- -f ~/company/.vcspull.yaml \
145- -w ~/work/
101+ $ vcspull add ~ /study/python/pytest-docker -f ~ /configs/python.yaml
146102```
147103
148104## Handling duplicates
149105
150- vcspull merges duplicate workspace sections by default so existing repositories
151- stay intact. When conflicts appear , the command logs what it kept. Prefer to
152- resolve duplicates yourself? Pass ` --no- merge` to leave every section untouched
153- while still surfacing warnings .
106+ vcspull merges duplicate workspace sections before writing so existing
107+ repositories stay intact. When it collapses multiple sections , the command logs
108+ a summary of the merge. Prefer to inspect duplicates yourself? Add
109+ ` --no-merge ` to keep every section untouched .
154110
155111## After adding repositories
156112
157- After adding repositories, consider:
158-
159- 1 . Running ` vcspull fmt --write ` to normalize and sort your configuration (see {ref}` cli-fmt ` )
160- 2 . Running ` vcspull list ` to verify the repository was added correctly (see {ref}` cli-list ` )
161- 3 . Running ` vcspull sync ` to clone the repository (see {ref}` cli-sync ` )
113+ 1 . Run ` vcspull fmt --write ` to normalize your configuration (see
114+ {ref}` cli-fmt ` ).
115+ 2 . Run ` vcspull list ` to verify the new entry (see {ref}` cli-list ` ).
116+ 3 . Run ` vcspull sync ` to clone or update the working tree (see {ref}` cli-sync ` ).
162117
163118## Migration from vcspull import
164119
165- If you previously used ` vcspull import <name> <url> ` :
120+ If you previously used ` vcspull import <name> <url> ` , switch to the path-first
121+ workflow:
166122
167123``` diff
168124- $ vcspull import flask https://github.com/pallets/flask.git -c ~/.vcspull.yaml
169- + $ vcspull add flask https://github.com/pallets/flask.git -f ~/.vcspull.yaml
125+ + $ vcspull add ~/code/ flask --url https://github.com/pallets/flask.git -f ~/.vcspull.yaml
170126```
171127
172- Changes:
173- - Command name: ` import ` → ` add `
174- - Config flag: ` -c ` → ` -f `
175- - Same functionality otherwise
128+ Key differences:
129+
130+ - ` vcspull add ` now derives the name from the filesystem unless you pass
131+ ` --name ` .
132+ - The parent directory becomes the workspace automatically; use ` --workspace `
133+ to override.
134+ - Use ` --url ` to record a remote when the checkout does not have one.
176135
177136[ pip vcs url ] : https://pip.pypa.io/en/stable/topics/vcs-support/
0 commit comments