How do version control ( git, version control) using notebook jupyter?

Asked

Viewed 385 times

1

I recently started programs in Python using the Jupyter Notebook (web) and wanted to give a push in my Github repository.

I cloned my repository through cmd, I changed the document, I did a lot of things, now it’s saved on my machine and I want to go up on Github. I have to close the kernel and do the git push at cmd?
I do it inside JN itself?
There’s a step for this?

I appreciate the help!

  • Maybe the question is how to use git. If I’m not mistaken the jupyter file . ipynb works like another . txt, . c, . py, etc..

1 answer

1

That - basically, Jupyter stores all session data in type files .ipynb. So it’s these files that you have to keep versioned.

For this it is important to stop the Jupyter server (I do not know his mechanisms very deep, it may be that just close the kernel is enough) - a good indicative will be the date-and-time of the last modification of your file .ipynb.

You say the document is already in the repository, so I guess it is . ipynb that interests you.

Terminal (cmd in Windows), you have to type two git commands: first a "commit" followed by a push:

git commit [nome_do_arquivo].ipynb -m "[descrição curta das alterações]"
git push

If everything is ok, both commands will say this on your exit.

if the file is not versioned

If the file .ipynb not yet in the repository, it must be added before, with the command git add:

git add [nome_do_arquivo].ipynb

Then the commands are commit and push will function as above.

  • Hello jsbueno, thanks for the instructions but I must be doing something wrong. So I created the file . ipynb after cloning the repository, which means it’s not originally on my github. When I do his commands, he does not recognize the file to commit, precisely because it does not yet exist in my environment. Since I needed to shut down the computer, now I only have the updated repository on my machine. If I clone the repository again, I’ll overwrite it, right? How do I reference that that’s the repository I want to update?

  • I updated the response to this case.

  • But how will he know which repository I’m talking about?

  • you said you had already set the repository part - if the file is in a folder that came from the github repository, that folder has another folder named ". git", which has the information of verring and remote repositories.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.