Skip to content

GoodGitPractices

steveraysteveray edited this page Apr 6, 2023 · 7 revisions

This is a brief cheat sheet for good practices as we use Github for QUDT. For general guidance on contributing to public projects on Github, please see this guidance, and in particular the section on submitting a pull request. There are essentially three stages:

  1. Making changes to file(s)
  2. Submitting a pull request for review
  3. Reviewing and merging

Making changes to file(s)

  1. Ensure you are up to date on your fork of the repo:
    git checkout main
    git pull
  1. Create a new branch for your work. Please name your branch beginning with your initials, a hyphen, then some topical name:
    git checkout -b srr-mynewbranch
  1. Do all your changes and additions and testing on this branch (srr-mynewbranch in above example). This might last for days or more.
  2. Check that all the changed files are the ones you intended using the 'git status' command below.
    git status
  1. If so, add them for tracking (you can also add individual files or files satisfying regular expressions):
    git add -A
  1. Frequently commit, so that each change can be tracked and rolled back if needed.
    git commit -m 'Descriptive message about the change'
  1. Bring in the latest changes in main before you push:
    git checkout main
    git pull
    git checkout srr-mynewbranch
    git merge main
  1. Push your branch to the remote. The first time, you'll need to create the branch on the remote:
    git push --set-upstream origin srr-mynewbranch

Later, when you are on your branch, you can just say

    git push

Submitting a pull request for review

  1. This is most easily done via the Github website. Once you have pushed your branch, it will show up under the "branches" tab. Just click the button that says "New pull request". Pay attention to what the pull-downs say about what repository and branch is being merged into what other repository and branch. You will normally request to merge from your own fork/branch into the qudt/qudt-public-repo main branch.

Reviewing and merging

(done by a member of the Approver team).

(File last modified 2020-02-19 by Steve Ray)