TopNotchNote
Notes that matter
git vs github
git is the version-control tool that runs on your machine. GitHub is a
website that hosts git repositories and adds collaboration features on top: pull requests, issues, code
review, project boards, and CI/CD (Actions). You can use git without GitHub, but GitHub is built entirely
on top of git — everything below assumes you already know the basics from the git
cheat sheet.
creating a repository
Click the + menu (top right of github.com) → New repository. Choose a
name, public or private visibility, and optionally initialize with a README, a .gitignore template, and a license. Initializing with a README creates the
first commit for you, so you can clone immediately instead of pushing an empty repo.
git remote add origin git@github.com:<user>/<repo>.git | | connects an existing local repo to a new, empty GitHub repo |'gh_repo1'
git push -u origin main | | pushes and sets main to track origin, so future git push/pull need no arguments |'gh_repo2'
ssh setup
SSH keys let you authenticate to GitHub without typing a password or token on every push. Generate a
key once per machine, then register the public half with GitHub.
ssh-keygen -t ed25519 -C "your_email@example.com" | https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent | generates a new SSH key pair (press enter to accept the default file location) |'gh_ssh1'
eval "$(ssh-agent -s)" | | starts the ssh-agent in the background |'gh_ssh2'
ssh-add ~/.ssh/id_ed25519 | | adds your private key to the running ssh-agent |'gh_ssh3'
Copy the public key with
cat ~/.ssh/id_ed25519.pub, then paste it into GitHub under
Settings → SSH and GPG keys → New SSH
key.
ssh -T git@github.com | https://docs.github.com/en/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection | tests the connection; a successful reply greets you by username, it does not open a shell |'gh_ssh4'
cloning: ssh vs https
git clone git@github.com:<user>/<repo>.git | | clone over SSH — no prompts once your key is set up above |'gh_clone1'
git clone https://github.com/<user>/<repo>.git | | clone over HTTPS — works through most firewalls, but needs a token instead of a password |'gh_clone2'
GitHub removed password authentication for git operations in 2021. If you clone over HTTPS, the
"password" prompt expects a personal access token, not your account password.
forking and pull requests
A fork is your own copy of someone else's repository, made when you don't have push
access to the original. The usual flow: fork → clone your fork → create a branch → commit → push to your
fork → open a pull request (PR) back to the original repo.
Mark a PR as draft while it's still a work in progress — it can't be merged and
doesn't notify reviewers until you mark it "Ready for review". Request specific reviewers from the PR
sidebar; GitHub can also auto-assign reviewers via a
CODEOWNERS file.
| Merge strategy | What it does |
|---|---|
| Merge commit | Keeps every commit from the branch, plus a new merge commit — full history, noisiest log. |
| Squash and merge | Collapses the branch into one commit on main — clean log, loses individual commit history. |
| Rebase and merge | Replays the branch's commits onto main individually — clean log, keeps individual commits. |
issues
Issues track bugs, tasks, and discussions. Attach labels (bug, enhancement, ...),
assignees, and milestones to organize them. Reference an issue from any
commit message or PR description with a closing keyword, and it closes automatically once that commit
lands on the default branch.
git commit -m "fix off-by-one in pagination, closes #42" | | closes/fixes/resolves + #number auto-closes issue 42 on merge |'gh_issue1'
code review on github
Review a PR's Files changed tab, comment on specific lines, and optionally propose
an exact fix with a
```suggestion code block — the author can apply it with one click.
Submit your review as Comment, Approve, or Request changes;
a repo can require at least one approval before a PR is mergeable (see branch protection below).
github search
github.com/search accepts qualifiers to narrow results by repo, language, author, and more —
combine several in one query.
| Qualifier | Example | Narrows to |
|---|---|---|
| user: / org: | user:babakpst | repos owned by a user or organization |
| repo: | repo:owner/name | a single repository |
| language: | language:python | code written in a specific language |
| is: | is:pr is:open | issue/PR state |
| stars: | stars:>500 | repos above a star count |
| filename: / path: | filename:package.json | files by name or directory |
keyboard shortcuts
| Key | Where | Does |
|---|---|---|
| shift + ? | anywhere | opens the full keyboard-shortcuts help dialog |
| t | inside a repo | opens the fuzzy file finder |
| s or / | anywhere | focuses the search bar |
| . | inside a repo | opens the repo in github.dev, a web-based VS Code |
permalinks
A normal file URL points at a branch, so the line numbers can drift as the branch changes. Press
y while viewing a file to rewrite the URL to point at the exact commit instead — safe
to share, it never moves.
To link specific lines: click a line number (shift-click for a range), then use the ...
menu that appears → Copy permalink. This bakes both the commit and the line range into
the link.
comparing branches or commits
Append
/compare/<ref1>..<ref2> to a repo's URL to diff two branches, tags, or
commit SHAs in the browser, e.g. github.com/<user>/<repo>/compare/main..feature-branch.
Two dots compares the refs directly; three dots (main...feature-branch) compares against
their common ancestor instead, which is usually what you want when reviewing a feature branch.
github actions (ci/cd)
Workflows live in
.github/workflows/*.yml and run on events like push or
pull_request. A minimal test workflow:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "Running tests..."
branch protection rules
Settings → Branches → add a rule for
main. Common protections: require a pull request
(and at least one approval) before merging, require status checks (like the CI workflow above) to pass,
and block force-pushes or direct pushes to the branch entirely.
github cli (gh)
gh auth login | https://cli.github.com/manual/gh_auth_login | authenticates the CLI with your GitHub account |'gh_cli1'
gh repo clone <user>/<repo> | https://cli.github.com/manual/gh_repo_clone | clones a repo without leaving the terminal |'gh_cli2'
gh pr create | https://cli.github.com/manual/gh_pr_create | opens a pull request from the current branch |'gh_cli3'
gh pr view --web | | opens the current branch's PR in the browser |'gh_cli4'
gh issue list | https://cli.github.com/manual/gh_issue_list | lists issues without leaving the terminal |'gh_cli5'
personal access tokens
Since password auth is gone, HTTPS git operations, the API, and headless
gh use a
personal access token instead — created under Settings → Developer settings. Prefer a
fine-grained token scoped to one repo and the minimum permissions it needs over a
classic token, which grants broad, account-wide access.
github pages
Settings → Pages lets you publish a repo (or one branch/folder of it) as a static website for free,
either from a plain branch or via a GitHub Actions build. A good fit for hosting docs or a runnable demo
next to a repo's source. Add a custom domain by placing a
CNAME file with the domain name
in the published folder.
related topics
Git Cheat Sheet — the underlying git commands GitHub's workflows are built on.
Git Hooks & Automation — the local equivalent of the branch protection and status checks covered above.
.gitignore Reference — keeping a repo clean before it ever reaches GitHub.
Git Hooks & Automation — the local equivalent of the branch protection and status checks covered above.
.gitignore Reference — keeping a repo clean before it ever reaches GitHub.