I find it hard to internalize the workflow, so here I have some commands to use with Docker Sandboxes.
Add the host repository as a Git remote
git remote add host /run/sandbox/source
git remote rm origin Pull branch changes from the host into the sandbox
In clone mode, run these commands in the sandbox after adding the host remote above.
Replace branch with the branch name.
# Update the sandbox's main branch
git switch main
git pull --ff-only host main
# Update an existing named branch in the sandbox
git switch <branch>
git pull --ff-only host <branch>
# Bring a new named branch from the host into the sandbox
git fetch host <branch>
git switch -c <branch> FETCH_HEAD Pull branch changes from the sandbox on the host
In clone mode, run these commands in the host repository while the sandbox is running. Replace name with the sandbox name and branch with the branch name.
# Update the host's main branch
git switch main
git pull --ff-only sandbox-<name> main
# Update an existing named branch on the host
git switch <branch>
git pull --ff-only sandbox-<name> <branch>
# Bring a new named branch from the sandbox onto the host
git fetch sandbox-<name> <branch>
git switch -c <branch> FETCH_HEAD