Skip to main content
Oxen Workspaces function like a β€˜repo within a repo’ – you can add, remove, and restore files to and from a workspace without affecting the repository it’s based off of.

Workspace Structure

A repository’s workspaces are stored in the workspaces folder of the .oxen hidden dir. Each workspace has a workspace_id or workspace_name with which it can be identified, as well as the commit_id of the commit in the repository that the workspace points to. You can have multiple workspaces for the same commit_id so long as they each have a different workspace_id Workspaces are useful when you want to work with a repository without downloading all of the data for it locally. To interact with one, you don’t have to have the remote repository’s contents pulled locally – you only need a local repo that’s pointing to the remote
They’re also useful for doing imports of large amounts of files to a server. When you use oxen workspace add, you’re not writing any data to your local machine – Oxen processes and uploads the files directly to the remote. This allows you to avoid copying the files to a local repository like you would if you use the add --> commit --> push workflow, speeding up the operation and saving space on your machine

Instantiating a Workspace

Create a workspace with a remote repository and a branch name.
If no branch name is provided, the default branch is used
On the server, this will base the workspace on the latest commit of the branch. As such, you can only create workspaces using branches that exist on the remote. Optionally, you can provide a name for the workspace
Named workspaces are persistent. When you commit a named workspace, its commit_id will be updated to the newly created commit. Use a named workspace if you want make multiple commits with the same workspace

List Workspaces

You can list the workspaces for a remote using oxen workspace list

Adding Files

Use oxen workspace add to stage files to the workspace. This uploads the files’ contents directly to the server

Removing staged files

If you want to remove files staged to a workspace, you can unstage them with oxen workspace rm --staged.

Removing files from the base repo

On the other hand, you can use workspaces to remove files from the repository they’re based on. Stage files for removal with oxen workspace rm

Commit Changes

When you’re finished staging changes, you can commit the workspace to merge them into the base repo. This will create a new commit on the remote branch.
If you don’t provide a branch, the commit will be made to a new branch on the remote
πŸŽ‰ You have now committed data to the remote repo! Note: If merge conflicts are found, the workspace commit will fail, and you’ll have to resolve them to continue