Intro to GitHub
(GO-centric version)
Nomi Harris
Chris Mungall
March 2021 (updated April 2022)
Who is GitHub for?
Part 1: GitHub for everyone
Part 2: GitHub for project managers
Part 3: GitHub for content providers (curators, schema developers, ...)
Part 4: GitHub for software developers
GitHub documentation: https://docs.github.com/en
See also:
https://oboacademy.github.io/obook/tutorial/github-fundamentals/
Key concepts
Organization
Repo 1
Repo 2
Issues
Content
Content
Issues
Organizations
An organization is an entity on GitHub that may correspond to an institution (such as a university or a lab) or to a meaningful grouping of repositories.
Example: The Gene Ontology Consortium is an organization
Repository (“repo”)
Organization
Example: geneontology
repository (repo)
Example: go-ontology
Desc: this is where the ontology files are stored
repository (repo)
example: helpdesk
Desc: add description
repository (repo)
example: go-announcements
Desc: add desc.
Repo “landing page”
Menu: code, issues, pull requests, etc.
Summary of most recent change in each subdirectory
Contents of README.md (info about the repo in Markdown format, which is used on GitHub to format text)
Every repo should have a README!
More info about Markdown: https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax
Teams
More about teams: https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/about-teams
Teams are groups of people in your organization that can have specific access permissions and can be alerted as a group.
Issues
GitHub issue tracker
Search issues
Find issues that have this text anywhere (including in comments)
Filter issues
Start typing name or username
Filter by any of these
Click a label to see all issues with that label
My Issues
More about using issues: https://data2health.github.io/mtip-tutorial/lessons/Lesson6.html
Creating an issue
Here’s a screencast showing the creation of an issue (in the Mondo repo): https://docs.google.com/presentation/d/1sRMROf5jH3lR31fr3I10umJVsH4lb3cEajd-vjHKATs/edit#slide=id.g9b7706cb95_0_95
Issue templates
Some issue trackers have templates to help structure issues
(but you can also just open a blank issue)
Filling in an issue template
Replace this text with your bug description. (Start on a new line, don’t add to the ## line.)
## is Markdown for “header”. Leave this text alone.
Use the “Preview” tab to see how your issue looks
Creating an issue: Best Practices
Example: a good issue
Tag relevant people
Short but descriptive title
Describes the bad behavior, and why it’s a problem
Desired outcome
clear conditions for closing the ticket
Example: a bad issue
Title is vague
No context (Which browser/OS? What URL were you looking at? What happened?)
More about issues: https://guides.github.com/features/issues/
Make issue titles actionable
Non-actionable
Better
More about issues: https://guides.github.com/features/issues/
GitHub preferences
Notifications: How not to get spammed
Notifications: How not to get spammed (cont.)
2) Go to https://github.com/watching and click “Unwatch all” to unsubscribe from all repos.
3) Use the “watch” menu for the few repos you really do want to watch.
4) You can also “subscribe” to specific
issues or PRs.
“Participating and @mentions” is a good notification level for most repos
Part 1: GitHub for everyone
Part 2: GitHub for project managers
Part 3: GitHub for content providers (curators, schema developers, ...)
Part 4: GitHub for software developers
GitHub documentation: https://docs.github.com/en
Project management in GitHub
You don’t need to use all of these together!
Key concepts
Organization
Repo 1
Repo 2
Issues
Content
Content
Milestone
Issues
Contributors
Project
Team
Contributors
Labels
Labels: Best Practices
Tip: Avoid too many labels
Probably too many
Tip: Avoid too many labels (cont.)
Better
“Standard” tags
Making connections
Mention people (or teams): @
Cross-reference other issues: #
Start typing part of a name--autofill will make suggestions
Notifies the mentioned user or team
Type an issue number or some text
Superissues
“Superissues” show progress towards completion
Regular issue
Superissues: how to create
In issue description, list tasks preceded by checkboxes
How to add checkboxes:
In Markdown, -[ ] (with a space between the square brackets) makes an unfilled checkbox, -[x] a filled one]
Adding a checklist is a good way to make sure “todos” don’t get lost in a wordy issue!
More about using Markdown to style text in GitHub: https://guides.github.com/features/mastering-markdown/
You won’t see a superissue progress bar unless the checkboxes are in the FIRST block of text in the issue.
Milestones (per repo only)
More about milestones: https://docs.github.com/en/github/managing-your-work-on-github/about-milestones
Project boards
More about project boards: https://docs.github.com/en/github/managing-your-work-on-github/about-project-boards
Projects can include issues from multiple repos (but not multiple organizations)
Not just issues--can also add “notes”
Mouse over progress bar for more details
Only projects at the Organization level can link to multiple repos
Projects at the Organization level: https://github.com/geneontology/go-ontology/projects
Projects at the repo level: https://github.com/geneontology/go-ontology/projects
Tip: a little issue curation goes a long way
Configuring issue templates
Template files go in .github/ISSUE_TEMPLATE
Issue templates can also:
Here’s what users see when they start to create a new issue
Permissions
GitHub has two tiers of permissions, Organization and Repository, and a few permission levels within each:
More about permissions: https://docs.github.com/en/github/setting-up-and-managing-organizations-and-teams/repository-permission-levels-for-an-organization
Anyone with Owner or Admin permissions can accidentally delete a repo! 😲
Grant with caution!
Part 1: GitHub for everyone
Part 2: GitHub for project managers
Part 3: GitHub for content providers (curators, schema developers, ...)
Part 4: GitHub for software developers
GitHub documentation: https://docs.github.com/en
Setting up a new repo
The magic “.github” repo
The magic “.github” repo: example
Before / during / after creating .github/profile/README.md
Topics: defining your roles in the GitHub ecosystem
To help other people find and contribute to your project, you can add topics to your repository related to your project's intended purpose, subject area, etc.
Example: https://github.com/topics/obofoundry
Adding topics to a repo
Commit early and often
(can mark as draft)
Pull Requests (PRs)
See also: the OBO Academy tutorial on pull requests, https://oboacademy.github.io/obook/tutorial/pull-requests/
Creating a PR
Find the file; click the pencil to start editing
Make your edits
Simplest way: go to the file in GitHub and edit it right in your web browser
Creating a PR (cont.)
If you don’t have write permission, you can only propose changes
If you have write permission, you can commit or start a PR.
PRs are better for all but super-trivial changes.
Creating a PR (cont.)
This pulldown lets you choose regular vs. draft PR
Clicking “propose changes” opens a new page, with another chance to edit your commit message
PRs: draft vs ready to review
Linking an issue to a PR
‘#’ followed by part of an issue number or word -> autocomplete
Manual linking
PRs: peer review
Some repos require a minimum number of reviews to merge a PR
PRs: peer review
Requiring reviews to merge
This is a type of “branch protection rule” that a repo manager can add
More info: https://docs.github.com/en/github/administering-a-repository/managing-a-branch-protection-rule
PR review: suggesting changes
Always tie your work to a ticket!
WHO: Anyone working on content managed in GitHub (code, ontology, metadata yaml files, markdown docs, etc.)
GitHub Pages
GitHub Pages: from repo to website (example)
GitHub Pages: from repo to website (example, cont.)
But where did the top part about “Phenomics Workshop Series” come from? In this case, a Jekyll template.
https://github.com/monarch-initiative/phenomics/blob/master/docs/_config.yml
Part 1: GitHub for everyone
Part 2: GitHub for project managers
Part 3: GitHub for content providers (curators, schema developers, ...)
Part 4: GitHub for software developers
GitHub documentation: https://docs.github.com/en
What’s the difference between git and GitHub?
Why use GitHub?
GitHub is a website that wraps git along with other useful functionality, including
More about git
Best practices for collaborating
Work to a ticket
Closing issues manually
More about issues: https://guides.github.com/features/issues/
Branching and forking
Branching from the command line
(These instructions adapted from https://github.com/obi-ontology/obi#making-changes)
Comparing branches in a PR
Option to hide whitespace changes
Unified view
Split view
Finding the file that was changed
Commenting on a PR: general comments
In the “files changed” view, click the green “Review changes” button and enter your comments.
Commenting on a PR line by line
In the “files changed” view, hover over the line where you'd like to add a comment, and click the blue +.
To add a comment on multiple lines, click and drag to select the range of lines, then click the blue +.
When you're done commenting on specific lines, click Start a review.
There you can add general comments.
Resolving merge conflicts
base version (above the ======)
your version (below the ======)
If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask in our Slack channel
>>>>>>> branch-a
If you have questions, please open an issue, or, if it’s urgent, ask in our Slack channel.
Merging PRs
Don’t commit secrets
GitHub Actions
GitHub Actions
An event (e.g. a commit) can be set to trigger a workflow, which contains a job. The job then uses steps to run actions in order.
Workflows live in YAML files in the .github/workflows directory.
GitHub Actions
Simple example: Run a QC workflow when something changes in master
https://github.com/geneontology/go-ontology/blob/master/.github/workflows/qc.yml
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "ontology_qc"
ontology_qc:
# The type of runner that the job will run on
runs-on: ubuntu-latest
container: obolibrary/odkfull:v1.2.23
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Run ontology QC checks
env:
DEFAULT_BRANCH: master
run: make -j 4 ROBOT_ENV='ROBOT_JAVA_ARGS=-Xmx6G' travis_test
More examples:
Actions: see what happened
Click for more details about run
Migrating from Travis CI to GH Actions
(Instructions from Nico Matentzoglu)
Badges
GitHub permission levels
Permissions can be set at the organization level and at the repository level.
Organization (e.g. https://github.com/OBOFoundry) permission levels:
Repository (e.g. https://github.com/OBOFoundry/OBOFoundry.github.io) permission levels:
Example structure for teams and permissions
Example from OBO (James Overton)
Instructions and best practices for using GitHub for GO
Unused slides
Tip: “pin” your key repos
Lots of repos!
Maintainers have option to pin a subset