There are two ways to work with git projects in Jupyter Lab. You may either use the git extension for Jupyter Lab for a point-and-click interface, or issue git commands directly on the command line.
Whether you are using the git extension or the command line, if you want to sync your local repo with a remote repo, you will need to create a remote repo on GitHub or GitLab. See our quickstart instructions here.
SESYNC’s Jupyter server has the Jupyter Lab git extension enabled. The extension is a user-friendly add-on for JupyterLab that lets you do basic git actions with a point-and-click interface. Access the extension by simply clicking on the git icon on the left-hand side of your screen in Jupyter Lab (you should see something like the screenshot below).
Check out this lesson by Anne Fouilloux if you are interested in learning more about using the git extension.
If you aren’t interested in using the git extension, you may disable it by going to the Extensions tab on the left-hand
side of the screen, and selecting Disable
under @jupyterlab/git
(see screenshot below).
If git in the command line is more to your liking, here are brief instructions for cloning your remote repository to your home directory, and then staging, committing, and pushing local changes you make.
git clone <url_of_your_repository>
(get the url from your GitHub/GitLab repository page)Note: We suggest you use SSH for the URL to avoid having to repeatedly enter your log-in credentials. If you’re not sure if you’ve set up SSH authentication, see these GitHub instructions.
cd <name_of_your_repository>
to navigate into your repositorygit pull origin main
to get current version of repo from GitHub/GitLab (See footnote 1)git status
to check the status of your repository. You should see that your file(s) is
now listed as modified under the section “Changes not staged for commit”.git add <filename>
git commit -m "your_commit_message_here"
git pull origin main
git push origin main
If you’re confused about the differences between git, GitHub, GitLab, check out our FAQ here.
If you’re an RStudio user and would like to work with git, check out our FAQ here.
In GitHub and GitLab repositories created before October 1, 2020, the default branch is called master
, not main
. You will need to replace main
with master
in the commands above if you are working with an older repo. ↩