Skip to main content
The magnet link command (alias: magnet init) connects the current directory to one of your Magnet workspaces. Subsequent CLI commands run from this directory (or any subdirectory) operate in the context of the linked workspace.

Usage

magnet link
If you belong to multiple workspaces, the CLI shows a picker. The selection is saved to .magnet/project.json.

Options

OptionDescription
--workspace <idOrSlug>Workspace id or slug. Skips the interactive picker.
--org <idOrSlug>Alias for --workspace.
--yesSkip confirmation prompts (for CI and scripts).

Examples

Link non-interactively (for CI):
magnet link --workspace my-team --yes

The .magnet folder

Why do I have a folder named “.magnet” in my project? The .magnet folder is created when you link a directory to a Magnet workspace.
What does the “project.json” file contain? The ID of the linked Magnet workspace (orgId), plus its slug and name (orgSlug, orgName).
Should I commit the “.magnet” folder? No, you should not share the .magnet folder with anyone. Upon creation, it is automatically added to your .gitignore file.
Like .git, the link is discovered by walking up from the current directory, so commands work from anywhere inside the linked project.