How to edit .gitignore in Jupyter Lab?

Viewed 9817

My .gitignore is not visible in Jupyter Lab Files tab. Is there any way to show hidden files there?

4 Answers

This is still an open issue in JupyterLab:

https://github.com/jupyterlab/jupyterlab/issues/2049

As a temporary workaround, you can start your jupyter lab via the below command (as mentioned in the above URL) to edit hidden files:

jupyter lab --ContentsManager.allow_hidden=True

JupyterLab currently lacks the ability to toggle hidden files in the browser.

You can simply rename the file in a terminal session to view/edit .gitignore as needed:

1) Create gitignore as TEXT file:

enter image description here

2) Rename file to gitignore (no preceding dot) in JupyterLab:

You can now view/edit in JupyterLab as needed.

3) Prior to pushing to GitHub, add the preceding dot by running the following in terminal:

mv gitignore .gitignore

Whenever you need to view/edit the file, change it back to visible:

mv .gitignore gitignore

...and edit the file using JupyterLab.

If you ever need to see the file listed, run the following in terminal:

ls -a

Now in AWS SageMaker Jupyter Lab, one can access .gitignore file by menu "Git -> Open .gitignore". enter image description here

Actual big brain solution ln -s .gitignore gitignore

Related