How to sync git notebooks into home workspace files

Hallo every, i am new to the datalore. Is there a way to sync my git repo notebooks into the home workspace files? I see that i can use the ipython magic to clone from a notebook cell. But how can i sync and download my notebooks from git repo into my datalore home?

Is the download and update files manually the only option?

1 Like

Hello @Yingding ,

Is there a way to sync my git repo notebooks into the home workspace files

Unfortunately, there is no option to sync notebooks from Datalore workspace to a git repo, but we’re considering adding such a feature in the future.

As a partial workaround you may extract your code to a .py file, place it in the Attached Files or Workspace Files folder and import it in the notebook - this way you will be able to sync it, but yes, it wouldn’t be convenient.

Please stay tuned in for updates!

Please take a look at this blogpost describing all possible ways to work with git in Datalore: How to Work With Git in Datalore | The JetBrains Datalore Blog

Thanks Alena,
Thanks Igro,
for your quick reply. The Blog post really helps me as datalore newbie to work with git.

I managed to create a init.sh file in my Home workspace files, and attached it to my notebook.

#!/bin/bash
git config --global user.email "xxx"
git config --global user.name "yyy"

tokenname="<tokenname>";
token="<personal_access_token>";

DIR="/data/notebook_files/<folder>"
GITURL="github.com/yyy/xxx.git"

# clone if not exist
if [ ! -d "$DIR" ]; then
    git clone https://${tokenname}:${token}@${GITURL} $DIR  
fi

it works perfect sofar. You saved my day.

2 Likes

Hi @Yingding, please take into account that since everything in /data/notebook_files is persisted between runs, therefore your repo won’t be updated next time the notebook is started. Maybe it makes sense to pull it if the directory exists

@artem.borzilov Thank you for your suggestion. It is a fantastic idea, i added pull to keep the git repo code up to date.

#!/bin/bash
git config --global user.email "xxx"
git config --global user.name "yyy"

tokenname="<tokenname>";
token="<personal_access_token>";

DIR="/data/notebook_files/<folder>"
GITURL="github.com/yyy/xxx.git"

# clone if not exist
if [ ! -d "$DIR" ]; then
    git clone https://${tokenname}:${token}@${GITURL} $DIR
else
    git -C $DIR pull;
fi
1 Like

@igro I’m testing out Datalore and git repo integration being more a part of the UI is a deal-breaker for me. Jupyterlab and VS Code both have built-in UI for importing git repos. I’m hoping this could be added as a feature soon.

2 Likes