This guide walks you through the process of setting up your Git credentials in Valohai to enable pushing from your Jupyter notebooks directly to your Git repository.
Steps
1. Generate SSH Keys
- Using the terminal:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
If you are not familiar with generating SSH keys, refer to our docs page on generating an SSH key pair.
It does not matter how you generate the keys.
2. Add Deploy Key to GitHub
- Go to your repository on GitHub.
- Navigate to Settings > Deploy keys.
- Click Add deploy key.
- Paste your public key, set a title, and check Allow write access.
- Click Add key.
3. Add Private Key to Valohai
- In Valohai, click on your name and select Manage Organization.
- Navigate to App Credentials.
- Click Add credentials.
- Set the hostname and paste your private key.
- Save the credentials.
4. Test the Setup
- Go to your Valohai project.
- Create a new notebook execution.
- Wait for the environment setup to complete.
- Once the notebook is active, open it.
5. Push to Git from Notebook
- Create a new notebook or open an existing one.
- Add your code or changes.
- Save the file you want to push.
- Open the terminal in the notebook environment.
- Run the following commands:
git status
git add <your_file>
git commit -m "Your commit message"
git push <branch>
Finally, you can verify that the push was successful by checking your GitHub repository.
Use a Separate Project or Branch
We recommend using a separate project or branch for testing Git pushes from notebooks to avoid potential issues in production environments.
Stop Notebook Execution
Always stop your notebook execution after finishing your work to avoid unnecessary resource usage.