Working with Git
Getting started
Open the DataSphere project:
-
Select the project in your community or on the DataSphere home page
in the Recent projects tab. - Click Open project in JupyterLab and wait for the loading to complete.
- Open the notebook tab.
Cloning a public GitHub repository
To clone a public repository:
- Under
File Browser in the left-hand navigation menu, create or select a folder to host the repository clone and navigate to that folder. - In the top menu, click Git and select Clone a Repository.
- In the window that opens, specify the repository URI and click Clone.
You will see the cloned repository folder in the
Cloning a private GitHub repository
To work with a private repository, you need a personal access token
To clone a private repository:
- Under
File Browser in the left-hand navigation menu, create or select a folder to host the repository clone and navigate to that folder. - In the top menu, click Git and select Clone a Repository.
- In the window that opens, specify the repository URI and click Clone.
- In the window that opens, enter the username and token to access GitHub, and then click Submit.
You will see the cloned repository folder in the
Creating a local repository
To get started with a local repository:
-
Under
File Browser in the left-hand navigation menu, create or select a folder to host the repository clone and navigate to that folder. -
In the top menu, click Git and select Initialize a Repository.
-
In the window that opens, click Yes.
-
Create a notebook file in the repository folder.
-
Add the notebook file to version control:
- Go to the
Git section. - On the Change tab, in the Untracked drop-down list, find the project file.
- Next to the file name, click
.
- Go to the
-
Make the initial commit:
- In the Summary field, enter a name for the commit.
- In the Description field, enter a description for the commit.
- Click Commit.
- In the window that opens, enter the name and email address of the commit author.
- Click OK.
The local repository is ready to go.
Creating a new branch
-
Under
File Browser in the left-hand navigation menu, create or select a folder to host the repository clone and navigate to that folder. -
Under
Git, expand the Current Branch drop-down list. -
Click New Branch.
-
In the window that opens:
- In the Name field, enter a name for the new branch.
- In the list, select the branch to base the new branch on. To quickly find the branch you need, use a filter.
- Click Create branch.
The created branch will appear in the list and will become active.
Committing changes to a local repository
To edit data and commit the changes to a repository:
-
Modify the files under version control.
-
In the top menu, click File and select Save All to save the changes.
-
In the left-hand navigation menu, go to
Git. -
The edited files will appear in the Changes list of the Changes tab. The letter M next to the file name means that the file has been modified.
-
Next to the file name, click
. This will index the changes and move the file to the Staged list. -
To commit the changes:
- In the Summary field, enter a name for the commit.
- In the Description field, enter a description for the commit.
- Click Commit.
- In the window that opens, enter the name and email address of the commit author.
- Click OK.
The changes are now committed to the repository.
Pushing changes to a remote GitHub repository
To work with a private repository, you need a personal access token
To push the saved changes to a remote repository:
-
In the left-hand navigation menu, go to
Git. -
Click
Push committed changes. -
In the window that opens:
- Enter your username with commit access to the remote repository.
- Enter your personal access token for GitHub.
-
Click OK.
-
Wait until Successfully pushed appears.
Changes are now pushed to the remote repository.
Pulling changes from a remote repository
-
Go to the
Git section. -
Click
Pull latest changes. -
Wait until Successfully pulled appears.
Changes are now pulled from the remote repository.
Saving results to GitHub
To work with a private repository, you need a personal access token
To save your project code to a new GitHub repository:
-
Create
a new empty GitHub repository. You can add theREADME
,license
, and.gitignore
files later. -
Create a local repository in your DataSphere project:
- Under
File Browser in the left-hand navigation menu, create or select a folder to host the repository clone and navigate to that folder. - In the top menu, click Git and select Initialize a Repository.
- In the window that opens, click Yes.
- Under
-
Map your local repository to the remote GitHub repository:
- In the top menu, click Git and select Manage Remote Repositories.
- In the window that opens, enter the remote repository name and address and click Add.
- Close the window for adding remote repositories.
-
Add all required files to version control:
- Go to the
Git section. - On the Change tab, in the Untracked drop-down list, find the project file.
- Next to the file name, click
.
- Go to the
-
Make the initial commit:
- In the Summary field, enter a name for the commit.
- In the Description field, enter a description for the commit.
- Click Commit.
- In the window that opens, enter the name and email address of the commit author.
- Click OK.
-
Push the changes to the remote repository:
- In the top menu, click Git and select Push to Remote.
- In the window that opens, enter the GitHub username you will be using and your access token for GitHub.
As a result, the files you added to version control will appear in the GitHub repository.