Working with Git
Getting started
Open the DataSphere project:
-
Select the relevant project in your community or on the DataSphere homepage
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 an existing public repository:
- Under
File Browser in the left-hand navigation menu, create or select a folder you want to clone the repository to, then go 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
Clone an existing private repository:
- Under
File Browser in the left-side navigation menu, create or select a folder you want to clone the repository to, then go 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-side navigation menu, create or select a folder you want to clone the repository to, then go 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 the commit name.
- 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-side navigation menu, create or select a folder you want to clone the repository to, then go 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 that the new one will be based on. To quickly search for the desired branch, use a filter.
- Click Create branch.
The created branch will display in the list and will become active.
Writing changes to a local repository
To edit data and write changes to a repository:
-
Change the files that are 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 be displayed in the Changes list of the Changes tab. The letter M next to the file name means that the file has been changed.
-
Next to the file name, click
. The changes are indexed and the file is moved to the Staged list. -
To commit the changes:
- In the Summary field, enter the commit name.
- 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 written 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 the remote repository:
-
In the left-hand navigation menu, go to
Git. -
Click
Push committed changes. -
In the window that opens:
- Enter the name of a user with write access to the remote repository.
- Enter your personal access token for GitHub.
-
Click OK.
-
Wait until Successfully pushed appears.
Changes are 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 pulled from the remote repository.
Saving results to GitHub
To work with a private repository, you need a personal access token
To save a project code to a new repository on GitHub:
-
Create
a new empty repository on GitHub. You can add README, license, and gitignore files later. -
Create a local repository in the DataSphere project:
- Under
File Browser in the left-side navigation menu, create or select a folder you want to clone the repository to, then go to that folder. - In the top menu, click Git and select Initialize a Repository.
- In the window that opens, click Yes.
- Under
-
Map the 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's 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. - In the Untracked drop-down list under the Change tab, find the project file.
- Next to the file name, click
.
- Go to the
-
Make the initial commit:
- In the Summary field, enter the commit name.
- 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 changes to the remote repository:
- In the top menu, click Git and select Push to Remote.
- In the window that opens, enter the username of the GitHub user you are going to work under and the token to access GitHub.
As a result, the GitHub repository should contain the files that you added to version control.