This is just a BASIC cheatsheet for a PR based workflow using git and GitHub, geared towards new users of git and GitHub. If you are a new user, I HIGHLY recommend you skip to the end and review the Recommended Resources, which includes a sample GitHub repo you can clone and which will guide you through using GitHub.
- Check what branch you are on and whether you have changes that you might need to carry over to a new branch
git status- If you are NOT on main, AND you have changes to carry over, this will hide them in a stash temporarily:
git stash- If you were NOT on main, switch to it:
git checkout main- Make sure your local main has all the changes in the remote repo (GitHub, aka origin/main) so you have a clean starting point:
git pull
- Create and switch to a new branch named
NEWBRANCHNAMEwhich will contain everything you want to PR. Usually a branch contains a single feature/improvement OR one or many bugfixes
git checkout -b NEWBRANCHNAME- IF you hid stuff in your stash before which you WANT to include in this branch, pop it off the stash:
git stash popDo the work!
- Edit files, trying to keep edit/save blocks to RELATED changes .
- Test the changes, take some screenshots while you do as these will go in your PR!!
- IF you do NOT have a linter pre-commit hook OR you have a backlog of linting to clean up, run your linter now (shellcheck, hadolint, markdownlint-cli) and at least clean-up the function/areas you were working in. Test one more time.
- Add your changes to the Index:
git add FILENAMES- Commit files to your LOCAL branch with a useful description, including any relevant Issue IDs. See Keywords in Issues and PRs for how.
git commit -m "Resolves #123. BRIEF_DESCRIPTION"- Push your commit to your remote branch (aka
origin/NEWBRANCHNAMEon GitHub):
git pushgit push NEWBRANCHNAME origin # If your config does not automatically push to origin- Repeat this block for more commits on this branch.
- From the Pull Request tab, there should be a banner with
NEWBRANCHNAME, asking if you want to create a PR - click that button! If not, there is a New button somewhere on that page: Base:main, Compare:NEWBRANCHNAME - Name this branch something useful, as the title will be used in the Autogenerated Release Notes.
- Make some words to describe what it is and how you tested it! Drop some screenshots for evidence. Here's a nice simple example of how I do it on my own: hdub-tech/bitwarden-directory-connector-containers#24
- Assign a reviewer!
- After it is Approved, click the merge button to merge your branch changes into
origin/main(remote) - Make sure any related Issues are closed.
Important
You do NOT need to cut a release for every closed issue or PR! Do things based on your timelines and rules.
TODO: Flesh this out
TODO: Flesh this out then add to ToC
TODO: Flesh this out then add to ToC
- Interactively learn GitHub skills
- GitHub Practice repo
- Fork and pull request practice repo
- GitHub docs: Best Practices for repositories
- GitHub's keywords for linking commits, issues, and PRs
- git documentation (The
gitman pages are also found usinggit --helporgit SUBCOMMAND --helporman gitorman git-SUBCOMMAND)