Using Git in Your Workspace

Overview

Git is fully supported in Domino workspaces in Git-based projects with CodeSync, and imported Git repos. You can use common Git workflows like creating branches, committing (saving) your code, pushing or pulling changes, and more, all from within a workspace.




Methods for working with Git

There are a few ways of using Git in a Git-based project with CodeSync:

  • Git service provider and workspace sidebar – You can use your Git service provider’s (i.e. GitHub, etc.) user interface in collaboration with the sidebar actions (Sync to Git, Sync to Domino, Pull) in a Domino workspace to work with Git in your project. We recommend using Git in your project this way if you don’t have a lot of experience using Git with a terminal and instead prefer more guidance through a user interface. The rest of the screen captures on this page will demonstrate this method.

gbp-6-1

  • A terminal within a Domino workspace – Start a terminal in your workspace and use git just like you would on a local environment. For a refresher on common workflows with Git, see the following resource: Git cheatsheet.

gbp-4

  • Git plugins – Many IDEs integrate natively with Git or have plugins or extensions for Git, as shown in the screenshot below. These features are fully supported in Git-based projects via CodeSync technology, and you can use them to interact with Git in Domino. For information on how to use git version control with your preferred IDE, please see the following resources:

r-git-plugin




Commit code and push changes

Note

Note that in a Git-based project with CodeSync, the default working directory for your project’s code is /mnt/code.

To commit changes to your code and push them to your repository:

  1. Click on the File Changes option in the sidebar of your workspace.

  2. Under “Code”, view changes by expanding “Uncommitted Changes”.

  3. Enter a commit message.

  4. Click Sync to Git. Domino will sync and push your changes to the Git repository you’re using for your code.

The up (↑) arrow in the “Code” section indicates the number of commits that your branch is ahead of the upstream branch, while the down (↓) arrow indicates the number of commits that your branch is behind the upstream branch.

gbp-6

Attention

You may encounter merge conflicts when pulling or pushing code to your repository. To resolve merge conflicts, please refer to the section on resolving merge conflicts.




Commit all work

  1. Click on the File Changes option in the sidebar of your workspace.

  2. Under “All Changes”, enter a commit message.

  3. Click Sync All Changes. Domino will commit changes to your code and sync them to your Git repository, as well as commit changes to artifacts and sync them to the Domino File System (DFS).

Note

Note that in a Git-based project with CodeSync, the default working directory for your project’s code is /mnt/code.

gbp-12




Pull the latest changes

If you’re collaborating with others in a Git-based project with CodeSync, then you’ll need to pull the latest changes to your code from time to time.

To pull the latest changes from your Git repo:

  1. Click the File Changes option in the sidebar menu of your workspace.

  2. Under the “Code” section, click Pull. Domino will pull the latest changes into your workspace.

Note

Note that in a Git-based project with CodeSync, the default working directory for your project’s code is /mnt/code.

gbp-7

Attention

You may encounter merge conflicts when pulling or pushing code to your repository. To resolve merge conflicts, please refer to the section on resolving merge conflicts.




Resolve merge conflicts

On occasion, you may encounter merge conflicts in your code as a result of collaborating with colleagues. You can resolve merge conflicts in one of the following ways.

  • Git service provider and workspace sidebar

When merge conflicts arise, Domino will create a new branch with the conflicts in your repository and push them up to your Git service provider (i.e., Github, Bitbucket, etc.). To resolve the conflicts:

  1. Navigate to your Git service provider.

  2. Using your Git service provider’s user interface, create a pull request between the newly created branch and your original branch.

  3. Using your Git service provider’s user interface, merge the pull request.

  4. Navigate back to Domino. Do not pull any changes.

  5. Start a workspace terminal and reset the branch using git reset --hard origin/name-of-branch, where name-of-branch is the name of your original branch.

  6. Click Pull in the sidebar menu in your workspace. Domino will pull all of the latest changes (i.e., the resolved merge conflicts). Your branch should now be free of merge conflicts.

  • A terminal in your workspace

If you prefer to work in a terminal, you can resolve merge conflicts from within a workspace terminal. If you’re not familiar with the typical Git workflow to resolve merge conflicts, we recommend the following resource: Git merge conflicts.