Follow

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.

Screen_Shot_2018-05-22_at_4.55.14_PM.png

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.

Example

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.

Screen_Shot_2018-05-22_at_3.22.24_PM.png

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.

Screen_Shot_2018-05-22_at_3.23.48_PM.png

We can add and commit those changes as normal.

Screen_Shot_2018-05-22_at_3.25.19_PM.png

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.

Screen_Shot_2018-05-22_at_3.27.06_PM.png

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>.

Screen_Shot_2018-05-22_at_3.36.12_PM.png

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