Table of contents

Import, commit, and push projects on a Git repository

To support collaboration with stakeholders and the data science community at large, you can import and push project assets on a Git repository from Watson Studio Local.

Some files need to be in a specific Git repository folder in order to display and behave appropriately in Watson Studio Local.

If you pre-populate the repository, be sure to use the following folders in the repository for specific assets:

  • Jupyter notebooks (.ipynb files) > jupyter folder
  • Zeppelin notebooks (.json files) > zeppelin folder
  • RStudio assets > rstudio folder
  • Data sets > datasets folder
  • Models > models folder

Files that are not under one of these folders will be shown under Other Files on Watson Studio Local.

Collaborators in the Git repository can import assets from shared repositories and contribute their own assets to the project. The Git integration feature provides a flexible source code management method to track, back up, and collaborate on a project with multiple users. You can import, push, and pull changes from Git repositories with Watson Studio Local. All assets in the project will be on the Git repository when you push the changes.

Tasks to get integrated with the Git repository:

  1. Enable access to a Git repository from your Watson Studio Local account
  2. Import a project from a Git repository
  3. Add Watson Studio Local project assets to a Git repository
  4. Commit and push changes to a Git repository project
  5. Pull changes for a Git repository project

Other features of a Git repository integration:

Enable access to a Git repository from your Watson Studio Local account

Before you can import and push assets on a Git repository, you must enable your Watson Studio Local user account to access the Git repository. You enable access by creating a personal access token with the required access scope in the Git repository and linking the token to your Watson Studio Local account.

To create a personal access token:

  1. Depending on which Git repository you want to integrate with, generate your personal access token from one of the URLs below:
    GitHub
    https://github.com/settings/tokens
    GitHub Enterprise
    https://github.ibm.com/settings/tokens
    BitBucket
    https://bitbucket.org/site/oauth2/access_token
    BitBucket Server
    Go to Manage account > Account settings > Personal access tokens.
  2. From the Git repository page that opens, select at least the "repo" scope to import, commit, and push changes to the repository.

    Select 'repo' scope.

    Copy the generated access token.

  3. Add your personal access token. Open your profile settings, select the Integrations tab, and click add token.

    Add token

  4. Select the Token for the platform you generated the token on.
  5. Paste the token you copied in Step 3 in the Access Token field in Watson Studio Local.
  6. Give the new token a token name, and click Create.

Note that you can add more access tokens later in Profile > Settings under the Integrations tab, by clicking on add Token.

Import a project from a Git repository

After you save the access token, your project in Watson Studio Local can be created from an existing Git repository. You can choose the linking repository by selecting the user access token of that repository when creating the project. Private repositories are supported.

To link a Watson Studio Local project to an existing Git repository, you must have administrator permission to the project. All users must have permission to access the Git repository. Granting user permissions to repositories must be done in the Git repository.

To create a project from an existing Git repository:

  1. In your project list, click create project. Select the From Git repo tab.
  2. In the Token field, select the name of the access token that is linked to the Git repository that you want to import to your project.

    Select token

  3. Enter your Git repo URL in the Repository URL field. You can also change the name of your project, which by default is the repository name.

Now you can view the project and all its imported assets like any other project in Watson Studio Local in your project list.

Add Watson Studio Local project assets to a Git repository

You can add assets to a Git-linked project like you would add assets to a normal Watson Studio Local project. Specific assets types are published under designated folders in the Git repository:

  • Jupyter notebooks (.ipynb files) > jupyter folder
  • Zeppelin notebooks (.json files) > zeppelin folder
  • RStudio assets > rstudio folder
  • Data sets > datasets folder
  • Models > models folder

If the designated folder does not exist in the repository, it will be created when the project is committed and pushed.

Commit and push changes to a Git repository project

You can publish assets on the Git repository only by committing and pushing the changes to the project it is linked to.

To commit changes to a project:

  1. Select the Git Actions icon ( Git Actions) in the project action bar and click Commit.
  2. Select which files to commit, and type a message about the committed changes.

    Commit

  3. Click the Commit button.
    Tip: You can view the commit messages by navigating to /user-home/{uid}/DSX_Projects/{projectName} and running git log.

Only an Editor or Admin in the project can push changes. To push committed project changes:

  1. Select the Git Actions icon ( Git Actions) in the project action bar and click Push. Note that if your local copy is behind the repository copy, Watson Studio Local will advise that you pull changes first.

    Push

  2. Type a version tag for the release. This field is required to create a release from this project at a later time.
  3. Click the Push button.

From the Git Actions icon ( Git Actions) in the project action bar, you can click Commit history for a history of Git commits and who performed them. You can also add multiple tags to each commit, or revert to a specific commit.

Commit history

Pull changes for a Git repository project

You can update your assets on a Watson Studio Local project by pulling changes from its linked Git repository.

Make sure your project is already backed up in some way, such as exporting it as a .zip file or committing it on Git before pulling from a repository. The process of accepting changes could potentially overwrite changes you recently made in Watson Studio Local.

To pull changes from a repository, select the Git Actions icon ( Git Actions) in the project action bar and click Pull.

Merge changes for a Git repository project

Merge conflict

Whenever you pull changes and Watson Studio Local detects a Git merge conflict, you can resolve it in the following ways:

Automatic resolution: Strategy: theirs
Rerun the Git pull but automatically drop your local changes in a merge conflict.
Automatic resolution: Strategy: ours
Rerun the Git pull but automatically drop the remote changes in a merge conflict.
Manual resolution: Open terminal
Open a web terminal in a new page so you can resolve the merge conflicts by command line, for example, using git, vi, or windiff.

Open terminal

When finished, stage the conflicted files in the Git status summary panel and click the Complete Merge button.
Manual resolution: Resolve locally
Resolve merge conflicts locally using your own merge conflict solution:
  1. Export the project as a ZIP file to your local machine.
  2. Use your own tools such as Eclipse to resolve the conflicts.
  3. Drag the finished project into the Replace project page to upload it back into Watson Studio Local.
  4. In the Git conflict resolution summary panel, stage the conflicted files and click the Complete Merge button to overwrite the files.
Discard all changes and revert to a past commit (not recommended)
From the Git Actions icon ( Git Actions) in the project action bar, click Commit history and revert to a previous commit.

Until you resolve the merge conflicts, your project will wait in merge state.

Reset your Git repository project

You can reset your project so that it clones the Git repository that it is linked to. All assets in the project will be overwritten by the versions of the assets in the remote Git repository. To reset your project is a way to re-sync with all the collaborators, however it is to be used only if necessary, because you will lose all local changes made to the project.

To reset your project, select the Git Actions icon beside the project in your project list and click Reset Project.

This action will reset your project to whatever is in the master repository.