Working from a commit ID in Git

When you add an external Git repository to your project, you have the option to specify which state of the repository you want checked out by default in your runs and workspaces. You can specify a branch, tag, commit ID, or custom ref.

Commit IDs are unique SHA-1 hashes that are created whenever a new commit is recorded. If you specify a commit ID when adding a repository, Domino will always pull the state of the repository specified by that commit in a detached HEAD state. This represents a fixed point in the repository's history, and will not evolve over time like a branch.


Domino cannot automatically push to repositories it has pulled in this way. If you want to push changes to such a repository, you can use the workspace command line to manually commit and push to a new branch. Read Git repositories in Domino to learn more about interacting with Git in workspaces.


In this example, a repository called domino-manual has been added to our project with a specified commit ID. When we start our workspace, it gets pulled to /repos/domino-manual with the target commit checked out in a detached HEAD state. We can verify this in our workspace command line by running git status.


Suppose during the course of our workspace session we make a change to the repository. It will remain in the detached HEAD state, but Git will continue to track changes.


We can add and commit those changes as normal.


However, if we try to push from the detached HEAD state, we will encounter a fatal error. Git must have a branch to push to.


The solution is to create a local branch from our detached HEAD, check it out, and push to remote with git push -u origin <branch-name>.


Was this article helpful?
0 out of 0 found this helpful