Joshua's Docs - Github Cheatsheet, Notes, and Tips


What & Link Type
My Git Cheat Sheet Cheat Sheet
Github Help: Homepage Official Docs
Good Cheatsheet: tiimgreen/github-cheat-sheet Cheatsheet
Collection of cool Github resources: awesome-github Collection
Helpful browser extensions Collection

Your Github Profile

You can now customize your Github profile by creating a repo with the same name as your username, and editing with the content you want. For more details, follow this handy guide.

Here is my profile 👨‍💻 😊

Tips and Tricks


  • Get the size of a repo before cloning / forking /etc.

    • There is an API endpoint you can use to get repo info, including size. No login / creds required for public repos!

      • You can use a browser, cURL, or your fetcher of choice, then look for .size, which is in KB.
  • Get when a file was last modified, via Github API

Searching Github



  • You can search across all your own code, by filtering by your own username, with user:{your username}
  • You need to be logged in for many of the advanced search filters and code search
  • Sometimes languages don't show up in the language selector, but are still "filterable" via query string manipulation
  • You can find issues that someone commented on with is:issue commenter:{username} (S/O)


Ultimate one-stop-shop for finding badges -

Some of my favorite badges / most used:

  • Glitch Badges

    • From your project editor, you can find remix links and images by using Share -> Share Buttons
    • One official remix SVG URL is
    • For more details:

  • CodeCov:

    • URL:{USER}/{REPO}/branch/{BRANCH}/graph/badge.svg
    • MD: [![Code Coverage Badge]({USER}/{REPO}/branch/{BRANCH}/graph/badge.svg)]({USER}/{REPO}/branch/{BRANCH})
  • NPM:

    • MD: [![NPM Badge]({PKG_NAME})]({PKG_NAME})
  • Git tag version:

    • ![GitHub tag (latest SemVer)]({USER}/{REPO})
  • Netlify deploys

    • URL:{PROJECT_UUID}/deploy-status
    • Go to your settings page to find the ID & URL - e.g.{PROJECT_NAME}/settings/general#status-badges
  • Github repo badges (for if you are deploying markdown elsewhere, or just want GH stats)

    • Last commit:

      • MD: [![Last Github Commit]({USER}/{REPO})]({USER}/{REPO}/)
  • Git SHA

    • Checkout my blog post: "Git SHA Badges for Deploys"
    • If you just need the latest commit on Github, you can use:

      • This is explained in greater detail in the above linked blog post

Don't forget; you can link your badge to a webpage! In markdown, use [![Badge Alt Text](Badge_URL)](Link on badge click)

PRs (Pull-Requests)

Special Diffing Views

There are some special diff / comparison URLs for Github - check out "Things you didn't know you could diff in Github"

Dealing with PRs Locally - Method A

The best way, although maybe not the fastest, to deal with a PR locally is to set up a new local branch that tracks to the PR's branch - this is not so straightforward if the PR is for a forked repo.

Having a tracked branch will also allow you to push commits to the PR author's branch, assuming that they left the box checked that says "allow edits from maintainers".

In the case that the PR is to merge a branch from a fork (as is common with open-source work), here is what you need to do:

  1. Add the forked repo as a remote

    • git remote add {alias_for_fork} {fork_full_repo_url.git}
  2. Get the data from the new remote

    • git fetch {alias_for_fork}
  3. Now, you can either checkout their branch directly, or make a branch to track their branch:

    • Directly checkout: git checkout {alias_for_fork}/{pr_branch_name}
    • Via tracking branch: git checkout -b {mirror_branch_name} {alias_for_fork}/{pr_branch_name}

      • Example: git checkout -b fred-master fred/master

An alternative order for the above steps is to start with checking out a new PR branch based off your trunk, then pulling the remote onto it:

git checkout -b {pr_branch_name} {trunk_branch_name}
git pull {FORKED_PR_REPO.git} {trunk_branch_name}

the above approach is what Github recommends when you click the "view command line instructions" link in a PR.

If you want to add a commit to their PR branch, simply add the new commit to your tracking branch, and then:

  • If you checked the branch out directly, simply use git push
  • If you are using a "mirror" branch, use git push {alias_for_fork} HEAD:{pr_branch_name}

    • The git CLI should automatically prompt you to do this if you forget and try to just use push without options (it will throw a fatal: the upstream branch does not match the name of your current branch)

Dealing with PRs locally - Method B

A faster way to interact with and git checkout a PR locally, even before any of it is merged, by using this:

git fetch origin pull/{PR_NUMBER}/head:{LOCAL_BRANCH_TO_CREATE}

For example:

git fetch origin pull/4/head:pr-4

Just replace the PR # with the one you want!

For updating your local branch after the PR has been updated, you can use git pull origin pull/{PR_NUMBER}/head

For details, see this breakdown on how the command works

Keyboard Shortcuts!

Key Shortcut
? See all shortcuts!!! (also, here)
y Get page permalink (aka canonical link)
s or / Focus the search bar
CTRL + SHIFT + P Toggle between write and preview mode (markdown)

Github Actions and Workflows



  • Workflows vs actions?

    • Workflows are at the highest level of Github Actions - a workflow can contain all the sub-components of Github Automation pieces
    • Workflow -> [Job] -> [Step] -> [Action (GH, or Docker), Task, or Command]
    • The best diagram I have found (so far) that clearly shows this, is this one, from this article.
  • How do I get a nice badge image based on actions?

    • Docs: Adding a workflow status badge
    • Summary: The URL syntax is one of...:

      • If workflow has name:<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_NAME>/badge.svg
      • If no name field:<OWNER>/<REPOSITORY>/workflows/<WORKFLOW_FILE_PATH>/badge.svg
    • Remember URL encoding
  • How do I use secrets / passwords / .env vars?

    1. Add them under Repo -> Settings -> Secrets
    2. Within a workflow .yml file, pull in the secret with this syntax:

      • ${{ secrets.SECRET_NAME }}
  • Security: How do I keep my actions and workflows safe?

Markdown Source Last Updated:
Fri Apr 16 2021 12:33:05 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Tue Mar 10 2020 13:32:10 GMT+0000 (Coordinated Universal Time)
© 2021 Joshua Tzucker, Built with Gatsby