Using Git & GitHub
Save a history of your analysis and share changes with your team.
The basic concepts
- Repository: a project folder whose files are tracked by Git.
- Stage: select changes to include in a saved snapshot.
- Commit: record that snapshot with a description.
- Push: upload commits to GitHub.
- Pull: bring changes from GitHub into your working copy.
Work together with individual accounts
Use your own GitHub account and collaborate through a team repository. Keep passwords and access tokens private. Course-specific repository and authentication instructions will be provided with the computing environment.
For an introduction, use GitHub’s Hello World tutorial and About Git.
A working session
- Pull the latest changes before beginning.
- Coordinate with teammates about which files each person will edit.
- Work in small steps and save your notebook.
- Review the changed files and stage the intended changes.
- Commit with a message describing the work.
- Push the commit so teammates can access it.
Keep the repository reproducible
Include code, notebooks, a README, environment requirements, and data provenance. The README should explain the question, data sources, and how to run the analysis. Keep bulk datasets outside Git and document how to access them. Exclude credentials, tokens, and private configuration files.
Notebook collaboration
Coordinate edits to a notebook to avoid competing changes. Before sharing a completed analysis, restart the kernel and run the notebook from beginning to end. Check that the results do not depend on cells executed out of order.
If Git reports a conflict, preserve your work and ask for help before overwriting files.
Questions: Alex Bradley.