GH-900 Cheatsheet
GitHub Foundations
Download free PDFIntroduction to Git and GitHub
Git, GitHub and distributed history
- **Git** is an open-source distributed version control system. **GitHub** hosts Git repositories and adds collaboration, automation, security and community tools.
- A normal full **clone** includes repository history, allowing local commits, comparisons and branching offline. A **centralized** system keeps the authoritative history on a central server.
- A **commit** records a project snapshot plus metadata, a message and parent references. Its identifier identifies that commit; the message describes its purpose.
- A **branch** is a lightweight movable reference to a commit. New commits advance the current branch, isolating work without copying the entire project into a new repository.
- A **remote** is a named connection to another repository. **origin** commonly names the cloned repository; **upstream** commonly names the original project when working from a fork.
Files, branches and synchronization
- The **working tree** holds checked-out files. Modified changes enter the **staging area** with **git add**; **git commit** records the staged snapshot in local history.
- **Modified**, **staged** and **committed** describe the basic change lifecycle. **Tracked/untracked** is a separate distinction: an untracked file is not yet recorded by Git.
- **git switch -c feature** creates and switches to a branch; **git checkout -b feature** also does both. **git branch feature** creates the branch without switching.
- **git clone** creates a local repository copy. **git fetch** retrieves remote history; **git pull** fetches and integrates changes; **git push** publishes local commits to a remote.
Accounts and platform access
- A **personal account** represents a person. An **organization** owns shared resources and supports teams and repository permissions. An **enterprise account** governs multiple organizations.
- **GitHub Enterprise Cloud** is hosted by GitHub. **GitHub Enterprise Server** is self-hosted on infrastructure managed by the customer.
- **GitHub Desktop** is a Windows/macOS application for local Git work, including adding or cloning repositories, branching, committing and synchronizing. **GitHub Mobile** supports notifications and collaboration on the move.
- **GitHub Marketplace** helps discover integrations and Actions. Preview features may change before general availability; availability, support and service commitments depend on the feature.
Working with GitHub repositories
Repository structure and visibility
- A **repository** stores project files and revision history, with GitHub features such as issues, pull requests and settings around it. New repositories can include a **README**, **.gitignore** and **LICENSE**.
- **README** introduces the project and how to use it. GitHub selects a repository README from **.github**, then the repository root, then **docs**, in that precedence order.
- **.gitignore** identifies intentionally untracked files. It does not remove already tracked files or erase secrets from history. **LICENSE** states permitted use, modification and distribution.
- **Public** repositories are broadly visible; **private** repositories require access. Enterprise **internal** repositories are visible to enterprise members, with different treatment for outside collaborators.
- A useful **description**, README and repository **topics** improve discoverability. **Labels** categorize issues and pull requests within a repository.
Clone, fork and template
- A **clone** copies a repository to a local machine. A **fork** creates a related repository under another owner, useful for proposing upstream changes or developing an independent direction.
- A **template repository** supplies starter files and directory structure. A repository created from it starts an independent history; its default branch is included, with an option to include other branches.
- An administrator marks a repository as a **template** in repository settings. Templates standardize starting content; forks preserve a relationship and history for collaboration.
Documentation, sites and snippets
- A **wiki** organizes long-form project documentation. A private repository wiki follows repository read access; it is not automatically public.
- **GitHub Pages** publishes static websites from repository content through a publishing source or an Actions workflow. A wiki and a Pages site serve different documentation needs.
- A **gist** is a Git repository for sharing snippets or small files, with history and fork support. Fork a gist to preserve its ancestry while adapting it.
- A **secret gist** is unlisted, not access-controlled private storage. Anyone who obtains its URL can view it; never use it to store credentials.
Collaboration features
GitHub flow
- **GitHub flow** is a lightweight branch-based workflow: create a branch, make focused commits, open a pull request, discuss and review, validate, then merge.
- A **pull request (PR)** proposes changes from a **head/compare branch** into a **base branch**. The branches are different and may be in the same repository or an eligible fork.
- Commits belong to a **branch**, not to the PR itself. Pushing more commits to the head branch updates an open PR and lets you respond to review feedback.
- Run checks and validate behavior before merging. A feature-branch deployment can test the proposed change; deployment and merge order depend on the project workflow. Delete an unneeded feature branch after merging.
Review, checks and pull request states
- A PR may be **open**, **closed without merging**, or **merged**. **Draft** marks an open PR as work in progress; mark it ready for review before merging.
- **Draft PRs cannot merge** and do not automatically request code-owner review. Marking a draft ready can request the relevant code owners.
- **Conversation** shows discussion and events; **Commits** shows included commits; **Files changed** shows the diff and line comments; **Checks** shows automated check results and diagnostic output.
- Reviewers can **comment**, **approve**, or **request changes**. Approval alone does not override failing required checks, conflicts or other merge requirements.
- A **merge commit** retains branch history, **squash merge** combines the PR changes into one commit, and **rebase merge** replays commits on the base branch without a merge commit.
Issues, ownership and issue links
- **Issues** track bugs, ideas, tasks and feedback. PRs discuss proposed code changes. **Assignees** identify responsibility; **labels** classify work; **milestones** group related work toward a goal.
- Pin an important **issue** for visibility. Common labels include **bug**, **enhancement**, **documentation**, **question** and **help wanted**; repositories can customize them.
- Direct pushes require suitable write access. Read access to a public repository can still support contribution through a **fork and PR**. Assignment eligibility also depends on repository access and participation.
- Use a PR description such as **Fixes #42** to link and close an issue when the PR merges into the default branch. Supported families are **close/closes/closed**, **fix/fixes/fixed** and **resolve/resolves/resolved**.
- A plain **#42** reference creates a cross-reference without a closing instruction. Use **owner/repository#42** across repositories. The **Development** sidebar supports manual issue/PR links.
Templates and reusable writing
- **Issue templates** guide bug reports, feature requests or custom requests. **YAML issue forms** live in **.github/ISSUE_TEMPLATE** and collect structured fields; template configuration can set labels or assignees.
- A **pull request template** prepopulates the description with prompts or a checklist. It standardizes new submissions; it does not itself enforce review requirements or automatically label a PR.
- **Markdown** formats README files, descriptions and comments. Use **# Heading**, paired asterisks for emphasis, the link form **[text](URL)**, numbered lists, and **- [ ]** task items.
- **Saved replies** are reusable Markdown responses held in personal settings, with a title and message body. Insert one into an issue or PR response and adapt it to the conversation.
- **Slash commands** insert supported content in issue/PR descriptions and comment fields. The **Command Palette** navigates GitHub and runs context-sensitive commands such as switching branches or opening PRs.
Search, stars and notifications
- Combine search text with qualifiers: **org:Avocado is:issue label:guacamole "404 error"**. Use **repo:owner/name**, **is:open**, **assignee:USERNAME**, **author:USERNAME** and **mentions:USERNAME** to narrow results.
- Issue views offer shortcuts for work you created or that is assigned to you. Qualifiers support more precise searches across repositories or an organization.
- **Star** a repository to save it in your starred list and signal interest. Its **stargazers** page lists users who starred it. **Watch** and custom notification settings control repository updates.
- **Subscribe** to a particular conversation for ongoing updates. Opening, commenting on or being assigned to an issue/PR can subscribe you; mentions can also generate notifications.
- Use the notification inbox to triage threads, and configure email, web and mobile delivery. Mobile notification scheduling controls when push alerts reach your device.
Discussions and community conversations
- **GitHub Discussions** supports questions, ideas and open-ended conversation rather than a queue of code changes. Categories can include **General**, **Ideas**, **Show and tell**, **Q&A** and **Polls**.
- **Q&A** categories support marking a reply as an answer. **Polls** collect votes; pin a discussion to highlight it on the Discussions page.
- Use **Create issue from discussion** when a conversation reveals actionable work. The resulting issue and discussion are linked; this does not automatically assign an owner or implement the change.
Modern development
Codespaces and the web editor
- **github.dev** is a lightweight browser editor for repository files, opened with the **period (.)** key. It has no dedicated compute or terminal for building and running your application.
- **GitHub Codespaces** provides cloud-hosted development compute, a terminal and a configurable environment. Work in a browser or connect a supported local editor.
- Create a codespace from a repository, then **stop**, **resume**, **rebuild** or **delete** it as needed. Reopen an existing one from the Codespaces dashboard or the repository Codespaces menu.
- The **comma (,)** shortcut opens a repository in Codespaces or offers an existing environment. The **period (.)** shortcut opens github.dev instead.
- **devcontainer.json** defines repeatable project environment settings, tools and extensions. Account **Settings Sync** and **dotfiles** personalize editor settings and shell setup across codespaces.
- A codespace can have a custom **display name**, editor preference and shell configuration. An inactivity timeout **stops** it rather than committing or deleting work; timeout and retention settings are configurable.
Actions, workflows and runners
- **GitHub Actions** automates tasks such as build, test and deployment. A **workflow** is YAML in **.github/workflows**; an **event** triggers its execution.
- A workflow contains **jobs**; each job runs **steps** on a **runner**. A step runs a shell command or calls an action. Jobs can run in parallel or depend on other jobs.
- Triggers include **push**, **pull_request**, **issues**, **discussion_comment**, schedules and manual **workflow_dispatch**. A local commit alone does not notify GitHub or trigger a remote workflow.
- **GitHub-hosted runners** provide Linux, Windows and macOS environments. **Self-hosted runners** are machines you operate and secure; a codespace is a development environment, not automatically a runner.
- Workflows can call local actions, actions in accessible repositories, or Docker container actions. **Marketplace verified creator** badges identify verified publishers; review an action and its permissions before trusting it.
Copilot and developer responsibility
- **GitHub Copilot** is an AI coding assistant that can suggest code and help explain or develop solutions. Use an entitled account and the relevant integration for your supported editor or GitHub experience.
- Copilot uses model capabilities and supplied context to generate suggestions. Check generated code for correctness, security, licensing concerns and suitability; suggestions are not authoritative answers.
- Personal access and centrally managed organization access serve different needs. Organization-managed offerings add policy and seat administration; exact entitlements and data settings depend on the offering.
Project management
Projects, views and custom fields
- **GitHub Projects** organizes issues, PRs and draft items across repositories. Items remain linked to their repository data; project membership does not grant repository access.
- Create multiple views using **table**, **board** or **roadmap** layouts. Filter, sort, group and slice work to show the information each audience needs.
- **Custom fields** include text, number, date, single select and iteration. Iterations organize timeboxed work; roadmap views show items along a timeline.
- Projects can be **public or private** and can be reused as **templates**. Project visibility does not expose private repository issues to people who lack access.
- Built-in **workflows** can update status when items close or PRs merge, add matching items, or archive items automatically. Configure the trigger and action for the desired behavior.
Milestones and insights
- A **milestone** groups issues and PRs within a repository, with an optional due date. Its page shows open/closed work and completion progress; it is distinct from a cross-repository Project.
- **Projects insights** visualizes current item data and historical progress. **Current charts** summarize the present state; **historical charts** show changes over time.
- Repository **Insights** provides activity and contribution views. **Pulse** summarizes issues, PRs and commits; **Traffic** measures visits and clones; **Code frequency** shows additions and deletions.
Privacy, security and administration
Repository access and teams
- Organization repository roles build from **Read** to **Triage**, **Write**, **Maintain** and **Admin**. Read supports viewing; Triage handles issues/PRs without code push access; Write allows code contributions.
- **Maintain** supports repository management without the full set of sensitive administrator operations. **Admin** controls access and repository settings. Apply the least privilege needed.
- **Teams** group organization members for mentions and repository access. Teams can be nested; visibility is **visible** or **secret**, with restrictions on nesting secret teams.
- An **outside collaborator** has access to selected organization repositories without organization membership. Organization **base permissions** apply to members, not outside collaborators.
Organization and enterprise controls
- Organization owners set member base permissions and manage teams. Enterprise policies can constrain repository **visibility changes**, **deletion/transfer** and Actions use across organizations.
- **Enterprise Managed Users** are provisioned and managed through an identity provider. Managed accounts have restricted collaboration outside their enterprise and cannot create public repositories.
- **SAML SSO** federates authentication; **SCIM** automates identity provisioning. SSO and account provisioning serve different purposes.
- Actions policies can allow GitHub-authored actions, Marketplace verified creators, or specified actions and reusable workflows. Enterprise restrictions can limit what organizations are allowed to enable.
Account security and authentication
- Configure **two-factor authentication (2FA)** in personal password/authentication settings. Supported options include authenticator apps, security keys and GitHub Mobile; store recovery codes securely.
- An account password, a **personal access token** and an **SSH key** serve different authentication contexts. Keep tokens and private keys secret; a public SSH key can be shared.
- **SSO** is not itself a second authentication factor. Organization security requirements can apply to members and outside collaborators according to the configured policy.
CODEOWNERS and protected changes
- **CODEOWNERS** maps path patterns to responsible users or teams and automatically requests relevant PR reviews. GitHub searches **.github**, root, then **docs**; the file on the base branch applies.
- Code owners need appropriate repository write access. **CODEOWNERS does not grant access** or prevent file edits. Enable required code-owner approval through branch protection or a ruleset to enforce it.
- **Branch protection** and **rulesets** can require PR approvals, passing checks and other conditions before changes merge. They control changes to branches, not who may read an individual branch.
Vulnerabilities, secrets and safe disclosure
- The repository **Security** area brings together enabled **Dependabot**, **code scanning** and **secret scanning** alerts. Availability and access depend on repository settings, permissions and entitlements.
- **Dependabot alerts** identify known vulnerable dependencies. **Security updates** propose fixes for vulnerable dependencies; **version updates** keep dependencies current according to **.github/dependabot.yml**.
- **Code scanning** finds code vulnerabilities and errors using analysis tools such as CodeQL. **Secret scanning** detects supported exposed credentials; these solve different problems.
- **Push protection** blocks pushes containing supported secret patterns and explains the detection. Examples include supported API keys, OAuth tokens and service credentials; detection depends on supported patterns.
- If a real credential is exposed, **revoke or rotate** it and remove the leak. A blocked push or deleted file does not automatically revoke the credential.
- **SECURITY.md** explains supported versions and how to report vulnerabilities responsibly. Use the prescribed private reporting channel rather than exposing exploit details in a public issue.
Benefits of the GitHub community
Open source, InnerSource and support
- **Open source** allows use, modification and redistribution under an appropriate license. Public visibility alone does not provide an open-source license.
- **InnerSource** applies open-source collaboration practices within an organization or another limited audience. Shared ownership, discoverable repositories and PR review do not require making code public.
- Healthy projects explain contribution steps in **CONTRIBUTING.md**, set behavior expectations in a **code of conduct**, and use welcoming issues and discussions to help contributors participate.
- **GitHub Sponsors** lets people and organizations financially support eligible open-source maintainers. Maintainers set up a sponsored profile; stars and activity do not automatically create funding.
Profiles, recognition and discovery
- A profile can display a **biography**, picture and selected **pinned repositories or gists**. Pins are deliberately chosen highlights rather than an automatic ranking by stars or recent activity.
- The **contribution graph** can include qualifying commits, opened issues and proposed PRs. Commit credit depends on conditions such as author email and branch; not every Git operation counts.
- **Achievements** recognize milestones or participation. **Following people or organizations** helps surface public activity in your dashboard; watching a repository controls its notifications.