---
# System prepended metadata

title: GitHub

---

# GitHub


## Repositories


1. First [create](https://github.com/orgs/affinehealth/repositories) a repository on Github: use `New repositroy` button
  - choose a repository name
  - choose `public/private`
  - choose a `.gitignore` template (scala, nodejs, etc.)
  - choose a `license` (optional - can always add later)


2. `clone` the repository locally (SSH)
    - `git clone git@github.com:affinehealth/my-repo-name.git`

3. `ALWAYS` branch from `main` branch (source of truth)
    - `git checkout main`
    - pull latest: `git pull`
    - `git checkout -b [issue-number]-ticket-title`
    - Ex: `git checkout -b 4-add-github-workflows`
    
    *use the ticket number and title helps to **track** **work** and **branches***

4. When ready to push to GitHub for a PR, do:
    - `merge origin/main`
   this will make sure you have the latest code base from main. *Note: this may lead to conflicts wich will need resolving (check cli)*
   
5. `Push` to Github
    - first time push: `git push --set-upstream origin new_branch`
    - subsequent push: `git push`

6. on the repositories page there will be a banner recommending that you create a PR.
    - Create a PR and edit the template description
    - Set the `closes: #ticket-number`. *Github will close the ticket for you when the PR is merged*
    - make sure to **always** select `squash and merge` on the PR. It combines your commits into one large commit prior to merging into `main`.

7. Repeate 3-6 (continued work)


**Always** branch from `main` and use a **PR** on GitHub to `squash and merge` changes back to `main`
    