This guide describes a typical workflow for cloning an EPIK8s beamline with its Git subprojects, changing beamline files or operator interface (OPI) files, resolving conflicts, and aligning work with main.

Commands use <...> placeholders. Replace each placeholder with the actual repository URL, branch, path, or file. Do not type the angle brackets. Examples assume the default branch is named main; check the remote if a project uses another branch.

1. Understand the repository levels

A beamline checkout can contain multiple independent Git repositories. In this SPARC example:

beamline repository
└── opi                         submodule of the beamline
    └── epik8s-opi              submodule of opi
        ├── unimot-opi          submodule of epik8s-opi
        ├── unimag-opi          submodule of epik8s-opi
        └── ...

Each level records a commit ID for its child submodule. A commit made in opi/epik8s-opi is not automatically a commit in opi or in the beamline repository. To deliver the change through the whole tree, push the changed repository commit, then commit the updated submodule pointer in its parent, continuing up to the beamline root.

A submodule normally opens at the exact commit recorded by its parent, often with a detached HEAD. That is expected for use and deployment. Before making a change, switch to the intended branch inside the repository you are changing.

2. Clone the beamline and all subprojects

git clone --recurse-submodules <beamline-repository-url> <beamline-directory>
cd <beamline-directory>
git status --short --branch
git submodule status --recursive

What these commands do:

  • git clone creates a local copy of the beamline repository.
  • --recurse-submodules initializes submodules, including nested submodules, at the commits recorded by their parents.
  • cd enters the new checkout.
  • git status shows the current branch and any local changes.
  • git submodule status --recursive lists the selected commit for each submodule. A leading - means a submodule is not initialized; initialize it with the command below.

If the beamline repository was cloned without submodules, from its root run:

git submodule update --init --recursive

If a nested submodule is missing after its parent has been initialized, run the same recursive update again. To refresh the local URL configuration after .gitmodules changes, use:

git submodule sync --recursive
git submodule update --init --recursive

update checks out the commits recorded by the parent. It does not mean “move every subproject to the newest main.”

3. Start a change from the latest beamline main

From the beamline root:

git switch main
git pull --ff-only origin main
git switch -c feature/<short-change-name>

What these commands do:

  • git switch main selects the beamline's local main branch.
  • git pull --ff-only origin main fetches and advances it only if Git can do so without creating a merge commit. If this refuses, inspect the branch state rather than forcing it.
  • git switch -c ... creates a feature branch from the updated main.

If there is no local main yet, create one to track the remote branch:

git fetch origin
git switch --track -c main origin/main

Repeat this step in the specific subproject before changing it. The beamline's branch and each subproject branch are independent.

4. Modify and commit beamline-level files

Use this workflow for files owned directly by the beamline, for example deploy/values.yaml or beamline-specific IOC configuration:

# From the beamline root, edit the required files.
git status --short
git diff
git add deploy/values.yaml config/<path-to-file>
git diff --cached
git commit -m "Configure <beamline feature>"
git push -u origin feature/<short-change-name>
  • git diff reviews unstaged edits.
  • git add stages only the listed files. Prefer explicit paths when there are unrelated local changes.
  • git diff --cached reviews exactly what will be committed.
  • git commit creates a commit in the beamline repository.
  • git push -u publishes the feature branch and sets its upstream, so later pushes can usually use git push.

After review and merge on the Git host, update the local branch:

git switch main
git pull --ff-only origin main

5. Modify a file in opi/epik8s-opi

First ensure the parent submodules are initialized. Begin on the beamline feature branch created in section 3. Then create a corresponding feature branch in opi before working in its child:

git submodule update --init --recursive
cd opi
git status --short --branch
git remote -v
git branch --show-current
git switch main
git pull --ff-only origin main
git switch -c feature/<short-opi-change>
cd epik8s-opi
git status --short --branch
git remote -v
git branch --show-current
git switch main
git pull --ff-only origin main
git switch -c feature/<short-opi-change>

If main does not exist locally, create it from the remote after checking that origin/main exists:

git fetch origin
git switch --track -c main origin/main

Now make the OPI edit. For example, change a Phoebus display such as a .bob file in this repository, then review and commit it:

git status --short
git diff -- <path-to-display.bob>
git add <path-to-display.bob>
git diff --cached
git commit -m "Update <device> operator display"
git push -u origin feature/<short-opi-change>

Use the repository's actual branch and permissions. A contributor without push permission should push the branch to their fork and open a merge request or pull request against the canonical repository.

Record the new commit in each parent

After the epik8s-opi commit is pushed, return one directory to opi and record its new child commit:

cd ..
git status --short
git diff -- epik8s-opi
git add epik8s-opi
git commit -m "Update epik8s-opi submodule"
git push -u origin feature/<short-opi-change>

The cd .. above starts in <beamline>/opi/epik8s-opi and returns to <beamline>/opi. The next cd .. returns from opi to the beamline root. Check pwd if unsure.

Now the beamline root must record the changed opi commit:

cd ..
git status --short
git diff -- opi
git add opi
git commit -m "Update beamline OPI submodule"
git push -u origin feature/<short-beamline-change>

Important: these steps assume the parent opi repository has a feature branch and remote on which you are allowed to push. If the opi change is only a pointer update and should be delivered as part of the beamline change, create and push a feature branch in opi too. Never commit a parent pointer to a child commit that has not been pushed to a remote accessible to users and CI.

For nested submodules under epik8s-opi (for example, unimag-opi), the same rule applies one level further: push the child repository commit, commit that updated submodule pointer in epik8s-opi, push epik8s-opi, then record each parent pointer in turn.

6. The same OPI workflow using cd at every level

Some users find it easier to navigate one repository at a time instead of using git -C <path> .... These commands show the same operations explicitly. Start at the beamline root on the feature branch created in section 3:

cd opi
git status --short --branch
git switch main
git pull --ff-only origin main
git switch -c feature/<short-opi-change>

Then enter the nested repository:

cd epik8s-opi
git status --short --branch
git switch main
git pull --ff-only origin main
git switch -c feature/<short-opi-change>

Edit and commit the display in epik8s-opi:

git add <path-to-display.bob>
git diff --cached
git commit -m "Update <device> operator display"
git push -u origin feature/<short-opi-change>

Return to opi and commit the epik8s-opi pointer:

cd ..
git status --short
git add epik8s-opi
git diff --cached
git commit -m "Update epik8s-opi submodule"
git push -u origin feature/<short-opi-change>

Return to the beamline root and commit the opi pointer:

cd ..
git status --short
git add opi
git diff --cached
git commit -m "Update beamline OPI submodule"
git push -u origin feature/<short-beamline-change>

At each level, confirm git branch --show-current and git remote -v before committing or pushing. It is easy to be in a different repository than intended when directories are nested.

7. Align a feature branch with the latest main

Fetch the latest remote state from the repository whose feature branch you are aligning. For example, while inside epik8s-opi:

git fetch origin
git switch feature/<short-opi-change>
git rebase origin/main

git fetch downloads remote branch updates without changing the current files. git rebase origin/main replays your feature commits on top of the fetched main, producing a linear history. This changes commit IDs on the feature branch.

If the rebase completes, run the repository's checks, then update the remote feature branch:

git push --force-with-lease

Use --force-with-lease only for a branch you own and only after a rebase has rewritten commits already pushed. It checks that the remote has not advanced unexpectedly before replacing its branch history. Do not use plain git push --force as a routine fix. If the feature branch is shared, coordinate first or merge origin/main instead:

git merge origin/main

Align each repository separately. Rebasing the beamline feature branch does not update opi, epik8s-opi, or their children to their latest main. Update a submodule to a newer commit only intentionally, then commit the pointer changes in its parents.

8. Resolve ordinary file conflicts

A rebase or merge may stop with conflicts. First identify the repository and conflicted paths:

git status
git diff --name-only --diff-filter=U

Open each conflicted file. Conflict markers look like this:

<<<<<<< HEAD
content from the branch being rebased onto
=======
content from your feature commit
>>>>>>> feature/<short-change-name>

Edit the file to the intended final content and remove all conflict markers. Do not choose a side blindly: combine the changes when both are needed. Then stage the resolved files and continue the operation:

git add <resolved-file>
git rebase --continue

For a merge conflict, finish with a merge commit instead:

git add <resolved-file>
git commit

Repeat if Git reports more conflicts. Review the final diff and run relevant tests before pushing. To abandon an in-progress rebase and return to its starting state, use:

git rebase --abort

To abandon an in-progress merge, use:

git merge --abort

9. Resolve a submodule-pointer conflict

A conflict in a submodule pointer is different from a text-file conflict. The parent repository stores a commit ID, not the submodule's file contents. git status may report that a submodule has conflicting commits.

Enter the submodule and inspect its state and history:

cd <submodule-path>
git status --short --branch
git log --oneline --graph --decorate -12 --all

Decide which child commit should be used. Often the right resolution is to merge or rebase the relevant work inside that submodule first, push the resulting commit, and then return to the parent. From the parent repository, stage the selected submodule commit:

cd <parent-repository-root>
git add <submodule-path>
git status --short
git diff --cached
git rebase --continue

If there is no combined work to preserve and the team has agreed which side is correct, check out the intended commit inside the submodule, then stage the pointer in the parent. --ours and --theirs can be confusing during rebase, so inspect the actual commit IDs and contents rather than guessing which one means “my change.”

10. Common submodule checks and recovery

See which submodules are changed or uninitialized:

git status --short
git submodule status --recursive

A parent showing modified: <submodule> (new commits) usually means the submodule is checked out at a commit different from the pointer recorded by the parent. Inspect it before staging:

cd <submodule-path>
git status --short --branch
git log -1 --oneline
cd <parent-directory>
git diff -- <submodule-path>

To return a clean submodule to the exact commit recorded by its parent, from that parent repository run:

git submodule update --init -- <submodule-path>

This discards no committed work, but any uncommitted edits inside the submodule must be dealt with first. Check git status at every repository level before running recovery commands.

11. Final review checklist

Before asking for review or opening a merge request:

git status --short --branch
git diff --check
git submodule status --recursive
  • Confirm each intended file change is committed in the repository that owns that file.
  • Confirm each modified submodule pointer is committed in its parent repository.
  • Confirm every referenced submodule commit has been pushed to an accessible remote.
  • Confirm no unrelated files or secrets were staged.
  • Run the relevant project checks and describe the change and any deployment/configuration implications in the review request.
  • No labels