You have set up your environment, installed your packages, and written your first notebook. Before moving to any science, save this work permanently with Git. This habit — committing at every meaningful checkpoint — is one of the most valuable practices you can build as a computational scientist.
Connecting your project to GitHub¶
First, create a new repository on GitHub:
- Navigate to github.com and login to your account
- Click the + icon (top right) → New repository
- Name it
saxs-tutorial - Add a short description if you like
- Choose Public or Private
- Check Add a README file
- Check Add a .gitignore and select Python
- Click Create repository
Use the Python .gitignore template
The .gitignore file will automatically exclude specific files from any future commit. These are files that may be sensitive or routine files not necessary to save such as compiled files and virtual environment folders. You can always add more to .gitignore as needed.
Now link your local saxs-tutorial folder to the repository on GitHub. Open a
terminal inside VS Code by pressing Ctrl+` (or going to
Terminal → New Terminal), then run:
$ git init
$ git remote add origin git@github.com:yourusername/saxs-tutorial.git
$ git branch -M main
Replace yourusername with your actual GitHub username. You can find the exact
command on your new repository's page on GitHub — look for the section titled
…or push an existing repository from the command line.
Staging, committing, and pushing¶
Step 1: Check what Git can see.
Git lists new or modified files that have not yet been committed. Your notebook and
pyproject.toml should appear here.
Step 2: Stage the files you want to include.
Staging is a deliberate step — it lets you choose exactly which changes go into this commit. You do not have to include every modified file every time.
Step 3: Commit with a clear message.
Step 4: Push to GitHub.
The -u origin main flags only need to be included on the first push. After that,
git push alone is sufficient.
Navigate to your repository on GitHub and refresh the page — your files should be visible there.
Files that should not be tracked¶
Some files should never be committed to Git. The .venv folder can be several hundred
megabytes and can always be recreated from pyproject.toml using uv sync. The
.ipynb_checkpoints folder that Jupyter creates automatically is also unnecessary.
If you did not use GitHub's Python template when creating your repository, create a
file called .gitignore in your project root and add the following:
Then add and commit it:
How often should you commit?¶
There is no single correct answer. A useful rule of thumb: commit whenever you reach a state you would be unhappy to lose. In practice this means after writing a new function, after a plot looks the way you want it, or at the end of each working session.
Smaller, more frequent commits with descriptive messages are almost always better than
large, infrequent commits labeled stuff or final2.
Try It Yourself
- Add a new markdown cell to your notebook that describes what the sine wave plot is showing, in your own words.
- Run the notebook top to bottom to confirm everything still works.
- Stage and commit the updated notebook with an appropriate message.
- Push the commit to GitHub and confirm it appears on the repository page.
Solution
$ git add chapter_01_hello.ipynb
$ git commit -m "add description of sine wave plot to notebook"
$ git push
The commit message should reflect what specifically changed. If you also modified
other files, include them in the git add step before committing.
To verify on GitHub: navigate to your repository, click on
chapter_01_hello.ipynb, and confirm the new markdown cell is visible.
You now have a fully configured scientific computing environment and a version-tracked project on GitHub. Everything you build from here will be saved and recoverable.
What's next: Section 2 → — building a mathematical model of X-ray scattering from a sphere.