Skills
From your first commit to rewriting history, pull-request teamwork, Actions and the GitHub API.
A full path through version control with Git and collaboration on GitHub: repositories, branches, remotes and merging, then teamwork with issues and pull requests, undoing and rewriting history, hooks and tags, and finally automation with Actions, the CLI and the API. Each subject links the official documentation.
The subjects follow the roadmap.sh Git and GitHub roadmap.
Before typing commands, understand what problem Git solves: keeping a full, recoverable history of a project and letting many people change it in parallel. Then install it and introduce yourself to it.
A system that records snapshots of files over time so you can see who changed what, compare versions and return to any earlier state. Git is a distributed one: every clone holds the whole history.
It replaces "final_v2_really_final" copies with real history, makes experiments cheap through branches, lets a team merge work safely, and turns every bug hunt into a question of which commit introduced it.
Centralised systems such as Subversion keep history on one server; Git and Mercurial copy it to every clone, so commits, logs and branches work offline and are fast. Git stores snapshots, not file diffs.
Use your package manager (brew install git, apt install git) or Git for Windows, then confirm with git --version. macOS ships an Apple build through the Xcode command line tools that can lag behind.
A repository is your project plus a hidden .git directory holding every commit, branch and setting. Learn how to create one, how files move from the working tree through the staging area into commits, and how to read what you recorded.
git init turns the current directory into a repository by creating .git. Use -b main (or init.defaultBranch) to name the first branch, and remember that nothing is tracked until you add and commit it.
Reads and writes settings such as user.name, user.email, core.editor and aliases. git config --list --show-origin shows every value and the file it came from.
Settings live at three levels: --system for the machine, --global in ~/.gitconfig for your user, and --local in .git/config for one repo. The most specific wins — handy for a work email in one repository only.
The files you actually see and edit, checked out from one commit. git status tells you which of them are untracked, modified or unchanged compared with the index and HEAD.
Also called the index: the draft of your next commit. git add copies changes into it, git add -p stages only selected hunks, and git restore --staged takes something back out.
git commit saves the staged snapshot with a message, author and parent pointer. Make commits small and focused; -m sets a short message, while the editor lets you write a subject plus body.
Patterns for files Git should never track — build output, node_modules, .env. It only affects untracked files, so remove an already tracked file with git rm --cached before ignoring it.
git log lists commits newest first; --oneline --graph --all draws branches compactly, and git show <commit> prints one commit with its diff.
A branch is just a movable pointer to a commit, which is why Git branches are cheap to create and throw away. Work on a branch per feature or fix, then merge it back.
git branch name creates a pointer at the current commit; git switch -c name creates it and moves you onto it in one step. You can also start from another point: git switch -c fix origin/main.
git branch -m old new renames locally (-m new renames the current one). On a remote, push the new name, set upstream, and delete the old one; GitHub can rename the default branch and redirect for you.
git branch -d deletes a merged branch and refuses otherwise; -D forces it. Remove the remote copy with git push origin --delete name, and git fetch --prune drops stale remote-tracking refs.
git switch name moves HEAD and your working tree to another branch; older tutorials use git checkout name, which still works but also restores files. Commit or stash first if you have conflicting edits.
git merge feature brings another branch's commits into the current one, either by fast-forwarding the pointer or by creating a merge commit with two parents.
A remote is a named URL of another copy of the repository, usually on GitHub, that you exchange commits with. Locally Git tracks what it last saw there as remote-tracking branches like origin/main.
git clone <url> copies the whole history, sets up origin and checks out the default branch. --depth 1 makes a shallow clone for CI or huge repos.
git remote -v lists remotes, add, rename, remove and set-url manage them. A fork typically has origin for your copy and upstream for the original project.
git push uploads your commits, git push -u origin branch also sets the upstream. git pull is fetch plus merge (or rebase with --rebase or pull.rebase=true) of the upstream into your branch.
git fetch downloads new commits and updates origin/* refs without touching your branch, so you can inspect them with git log main..origin/main before deciding to merge or rebase.
GitHub hosts Git repositories and wraps them with collaboration tools. Set up an account and profile, learn the interface, and create repositories with the right visibility.
Sign up with a username you are happy to show employers, enable two-factor authentication, and add an SSH key or use a credential manager so pushes do not ask for a password.
A repository page has tabs for Code, Issues, Pull requests, Actions, Projects and Settings. Press ? for keyboard shortcuts, t for the file finder, and . to open the repo in the web editor.
Add a photo, name, bio and links, and pin your best repositories so visitors see real work first. Commits count toward your contribution graph only when their email is linked to your account.
Create a public repository with exactly your username as its name and a README.md; GitHub renders it at the top of your profile. Keep it short: who you are, what you build, how to reach you.
Create from the web UI or gh repo create, optionally with a README, licence and .gitignore. To publish an existing local project, create an empty repo, add it as a remote and push.
Public repos are visible to everyone and can be forked; private ones only to people you grant access. Making a repo public exposes its whole history, so scrub secrets first.
There are several ways to bring a branch into another, each leaving a different shape of history. Teams usually pick one — merge commits, squash or rebase — and enforce it in repository settings.
If the target has not moved, Git just slides its pointer forward, leaving no trace of the branch. --no-ff always creates a merge commit so the feature remains visible as a unit; --ff-only refuses anything but a fast-forward.
Replays your commits on top of another base, giving a straight line instead of a merge commit. It rewrites commit ids, so rebase only branches nobody else has built on.
Combine a branch's commits into one: git merge --squash, the "Squash and merge" button on GitHub, or squash/fixup in an interactive rebase. Tidy history, but the individual steps are gone.
When both sides changed the same lines Git stops and marks them with <<<<<<<, ======= and >>>>>>>. Edit to the right result, git add the file and continue, or git merge --abort to back out.
git cherry-pick <sha> copies one commit onto the current branch as a new commit — useful for back-porting a fix to a release branch. Overuse leads to duplicate changes across branches.
Most teamwork on GitHub happens through issues for tracking work and pull requests for proposing and reviewing changes. Agreeing on conventions for commits, branches and reviews keeps that flow smooth.
Cloning copies a repo to your machine; forking creates your own copy on GitHub that you can push to. Contribute to projects you lack write access to by forking, then cloning your fork.
Track bugs, tasks and ideas with a title, description, assignees and labels. Templates collect the details you need, and writing Fixes #12 in a pull request closes the issue on merge.
A proposal to merge one branch into another, with a diff, discussion, review and CI status in one place. Open drafts early, keep them small, and use branch protection to require reviews and passing checks.
Push a branch to your fork and open a pull request against the upstream repository. Keep the fork in sync via "Sync fork" or by fetching upstream, and allow maintainers to edit your branch.
On a personal repository you can invite people as collaborators, giving them push access. For finer-grained roles, move the repo to an organization.
Labels such as bug, good first issue or needs-review classify work so you can filter lists, drive project boards and trigger automation.
A short imperative subject around 50 characters, a blank line, then a body explaining why. Many teams adopt Conventional Commits (feat:, fix:) so changelogs and versions can be generated.
Use a predictable scheme such as feat/login-form or fix/123-null-crash: lowercase, hyphens, an optional type prefix and issue number. Slashes group branches in most tools.
One concern per pull request, a description that states what and why, screenshots for UI changes, and linked issues. A pull request template in .github/ keeps these consistent.
Reviewers comment on lines, suggest edits that the author can commit in one click, and then approve or request changes. Review for correctness and clarity first; let linters argue about style.
Before sharing, fold "fix typo" commits into the change they fix with git commit --fixup and git rebase -i --autosquash, so every commit builds and tells one story.
Conversation on issues, pull requests and discussions is where decisions get made. GitHub adds small tools that keep that conversation fast and searchable.
Reusable comment snippets stored on your account, inserted from the reply toolbar. Maintainers use them for recurring answers like "please add a reproduction".
Typing @username or @org/team notifies that person or team and subscribes them to the thread. Reference issues and pull requests with #123 to link them both ways.
Emoji reactions on issues and comments signal agreement without adding noise. Maintainers often sort issues by 👍 count to gauge demand.
A forum built into the repository for questions, ideas and announcements that are not actionable issues. Answers can be marked accepted, and a discussion can be converted to an issue when it becomes work.
Good repository docs answer what the project is, how to run it and how to contribute. GitHub renders Markdown everywhere and recognises a few special files.
GitHub Flavored Markdown adds tables, task lists, fenced code with syntax highlighting, alerts and Mermaid diagrams to plain Markdown. It works in READMEs, issues, comments and wikis.
The front page of a repository: what it does, a screenshot, how to install and run it, and where to get help. Keep commands copy-pasteable and up to date with the code.
A separate Git repository of Markdown pages attached to a project, for longer guides that would bloat the README. Clone it as <repo>.wiki.git to edit offline.
A CITATION.cff file in the repo root tells researchers how to cite your software; GitHub then shows a "Cite this repository" button with APA and BibTeX output.
A CONTRIBUTING.md explaining setup, coding standards and the pull request process; GitHub links it whenever someone opens an issue or PR. Pair it with a code of conduct.
git stash shelves uncommitted changes so you can switch branches with a clean tree, then git stash pop brings them back. Add -u to include untracked files, name entries with push -m, and inspect them with list and show -p.
Projects are spreadsheets and boards built on top of issues and pull requests, spanning any number of repositories. Custom fields, views and workflows turn them into a lightweight planning tool.
Break work into issues, group them with milestones or sub-issues, and add fields such as priority, size and iteration. A project view then answers "what is next and who has it".
The board layout shows items as cards in columns based on a status field; dragging a card updates the field. Limit work in progress per column to keep flow visible.
The roadmap layout plots items on a timeline using date or iteration fields, which makes it easy to spot overlapping work and slipping deadlines.
Built-in workflows set status when items are added, closed or merged, and can auto-add matching issues. For anything more, drive the project from Actions through the GraphQL API.
Once more than a few people share code, manage access through an organization with teams rather than inviting individuals repo by repo. Permissions then follow roles instead of memory.
Shared accounts that own repositories, packages and projects, with billing and security policies in one place. Members keep their personal accounts and can belong to many organizations.
Members belong to the organization; outside collaborators get access to specific repositories only. Repository roles range from read and triage through write and maintain to admin.
Teams group members, can be nested, receive repository permissions as a unit, and can be mentioned with @org/team. Combine them with CODEOWNERS to auto-request the right reviewers.
Git history is a graph of commits, each pointing to its parents. Reading it well — and knowing where you stand in it — is the foundation for undoing, comparing and rewriting.
Rebasing and squashing produce a straight line of commits that is easy to read and bisect; merge commits preserve the true parallel shape of development. Either is fine — be consistent.
HEAD is the pointer to what you have checked out, normally a branch name. HEAD~1 means its parent and HEAD^2 its second parent in a merge commit.
Checking out a commit or tag directly leaves HEAD pointing at a commit rather than a branch. Commits made there are easy to lose; create a branch with git switch -c to keep them.
Filter with --author, --since, -S "text" (pickaxe) and -- path; format with --oneline, --graph, --stat or --pretty=format:. main..feature shows what feature has that main lacks.
Git offers different undo tools depending on whether a mistake is unstaged, committed locally or already pushed. The rule of thumb: rewrite only what is private, revert what is shared.
Creates a new commit that applies the inverse of an earlier one, leaving history intact — the safe way to undo something already pushed. Reverting a merge needs -m 1 to pick the mainline.
Moves the current branch pointer to another commit and, depending on the mode, also resets the index and working tree. It rewrites local history, so avoid it on pushed commits.
git reset --soft HEAD~1 moves the branch back but keeps the changes staged — the quickest way to redo the last commit or squash several into one.
The default mode: the branch moves and the index is reset, but your edits stay in the working tree as unstaged changes, ready to be re-added differently.
Moves the branch and overwrites both index and working tree, discarding uncommitted work for good. Committed work it drops can usually still be found through the reflog.
git diff compares any two of the three trees — working directory, index and commits. Knowing which pair you are comparing avoids the classic "but I changed it" confusion.
git diff A B shows how to get from commit A to B; add --stat for a summary or -- path to limit files. git show <sha> diffs a commit against its parent.
git diff main..feature compares the two tips, while git diff main...feature (three dots) shows only what feature added since it branched — what a pull request displays.
git diff --staged (alias --cached) shows what is in the index compared with HEAD, i.e. exactly what the next commit will contain.
Plain git diff compares the working tree with the index, so it hides anything already staged. Use git diff HEAD to see staged and unstaged together.
Git lets you edit commits after the fact: change messages, reorder, split or drop them, even purge files from every commit. Every rewrite creates new commit ids, so coordinate before rewriting anything shared.
Replaces the last commit with a new one that includes the currently staged changes and, optionally, a new message. --no-edit keeps the message as it is.
git rebase -i HEAD~5 opens a todo list where you can pick, reword, edit, squash, fixup or drop commits and reorder lines. git rebase --abort returns to where you started.
The old built-in tool for rewriting every commit, for example to remove a leaked file. It is slow and error-prone; the Git docs themselves now recommend git filter-repo instead.
Overwrites the remote branch with your rewritten one. Prefer --force-with-lease, which refuses if someone else pushed in the meantime, and protect shared branches from force pushes.
A handful of tools that rarely come up on day one but save hours when they do: recovering lost commits, finding the commit that broke something, working on several branches at once and handling large or special files.
A local log of every position HEAD and each branch has held. After a bad reset or rebase, find the old commit in git reflog and git reset --hard back to it.
Binary-searches history for the commit that introduced a bug: mark one good and one bad commit, test what Git checks out, repeat. git bisect run <script> automates it.
git worktree add ../hotfix main checks out another branch in a second directory sharing the same repository, so you can fix something without stashing your current work.
A .gitattributes file sets per-path behaviour: line-ending normalisation with text=auto, marking files binary, custom diff and merge drivers, and linguist hints for GitHub.
Large File Storage keeps big binaries such as videos or datasets outside the repository, storing small pointer files in Git. git lfs track "*.psd" writes the rule into .gitattributes.
A submodule embeds another repository at a fixed commit inside yours. It suits vendored libraries you rarely change, but every clone and update needs extra commands, so consider a package manager first.
The parent repository records only a URL in .gitmodules and a commit id, so builds get exactly that version of the dependency. The downside is extra steps for everyone working on the project.
git submodule add <url> path adds one; clone with --recurse-submodules or run git submodule update --init. git submodule update --remote moves to the latest upstream commit, which you then commit.
Patches carry commits as plain text files, the way the Linux kernel still collaborates by email. git format-patch exports commits, git am applies them with authorship intact, and git apply applies a raw diff.
Hooks are scripts Git runs at points in its workflow — before a commit, after a checkout, when receiving a push. Use them to lint, test or enforce policies automatically.
Executable files in .git/hooks named after an event. That directory is not versioned, so share hooks via core.hooksPath or a tool such as Husky, lefthook or pre-commit.
Client hooks run on your machine and can be bypassed with --no-verify; server hooks such as pre-receive run on the remote and can reject pushes. On GitHub, enforce rules with branch protection and CI instead.
Runs before the commit message is requested; a non-zero exit aborts the commit. Typical uses are formatting and linting staged files, for example with lint-staged.
Receives the path of the message file and can reject or rewrite it — the usual place to enforce Conventional Commits with commitlint.
Runs before anything is sent to a remote and can stop the push, which makes it a good spot for a quick test suite or a guard against pushing to main.
Runs after git checkout or git switch updates the working tree; it cannot block anything. Useful for reinstalling dependencies when the lockfile changed between branches.
A server-side hook that runs once after a push has updated refs. Historically used to refresh info for dumb HTTP serving; post-receive is the more flexible choice for notifications and deploys.
Tags are fixed names for specific commits, normally release versions like v1.4.0. Unlike branches they do not move, which makes them the anchor for releases and changelogs.
Create annotated tags (git tag -a v1.0 -m "…") for releases — they carry author, date and message, and can be signed. git tag -l "v1.*" lists, git tag -d deletes locally.
git push does not send tags by default: push one with git push origin v1.0, or annotated tags reachable from pushed commits with --follow-tags. Delete a remote tag with git push origin --delete v1.0.
git switch --detach v1.0 inspects the tagged code in a detached HEAD. To fix something on an old release, branch from the tag: git switch -c hotfix-1.0 v1.0.
A release wraps a tag with notes, binaries and a "latest" marker. GitHub can generate notes from merged pull requests, and gh release create scripts it.
GitHub's built-in automation platform: YAML workflows in .github/workflows run jobs on hosted or self-hosted machines when events happen. It covers CI, releases, deployments and repository chores.
A workflow contains jobs, each job runs steps on a runner, and a step is either a shell command or a reusable action. Jobs run in parallel unless linked with needs.
Run tests and linters on every pull request, build and publish packages on tags, deploy on merge to main, label or close stale issues, and run nightly jobs.
Indentation-based key-value data. Watch for tabs (not allowed), unquoted values like on or yes being parsed as booleans by some tools, and | for multi-line run scripts.
The on: key: push, pull_request, workflow_dispatch for a manual button, release, workflow_call for reuse, with filters on branches, tags and paths.
on: schedule with a cron expression in UTC runs on the default branch. Runs can be delayed under load, and schedules are disabled after 60 days without repository activity in public repos.
runs-on picks the machine: GitHub-hosted ubuntu-latest, windows-latest or macos-latest, larger runners, or your own self-hosted runners. Never use self-hosted runners on public repos.
Objects such as github, env, secrets, matrix, steps and needs expose run information inside ${{ }}. Treat github.event fields like titles as untrusted input — never interpolate them straight into run.
${{ }} evaluates operators and functions like contains(), startsWith(), toJSON(), success() and failure(). Most often used in if: conditions to skip or gate steps.
Store credentials as repository, environment or organization secrets and read them via secrets.NAME; they are masked in logs. Plain configuration goes in vars or env. Prefer OIDC over long-lived cloud keys.
actions/cache restores directories by key, typically a hash of the lockfile, to skip reinstalling packages. Setup actions such as actions/setup-node have a built-in cache: option.
actions/upload-artifact saves build output, test reports or logs from a run, and download-artifact passes them to later jobs. Artifacts expire after a retention period.
Each run reports a status check on its commit and pull request; branch protection can require it. A status badge from the workflow page shows the latest result in your README.
Reusable actions published by GitHub and the community, used with uses: owner/repo@ref. Pin third-party actions to a full commit SHA, since tags can be moved.
gh brings pull requests, issues, releases, Actions and the API to the terminal. It is the fastest way to script GitHub and to stay in the shell during day-to-day work.
Install with brew install gh, winget or your Linux package repo, then gh auth login to authenticate through the browser. gh auth setup-git makes Git use the same credentials.
gh repo create, clone, fork, view --web and edit cover repository chores; gh repo sync updates a fork from its upstream.
gh issue list --label bug, gh issue create, view, comment and close handle issues without leaving the terminal; gh pr create, checkout and merge do the same for pull requests.
gh is preinstalled on GitHub-hosted runners and reads GH_TOKEN. --json with --jq gives stable output for scripts, and gh api calls any REST or GraphQL endpoint.
Everything you do on GitHub is also available programmatically. Authenticate with a fine-grained personal access token or an app, and respect rate limits and pagination.
Resource URLs under https://api.github.com, with a version header and pagination through Link headers. Octokit libraries wrap it for JavaScript, Ruby and .NET.
A single /graphql endpoint where you ask for exactly the fields you need across related objects in one request. Required for some features, such as Projects, and rate-limited by query cost.
Integrations that act on GitHub on behalf of an organization or a user are built as apps. Pick the type based on whose identity the integration should act with and how fine-grained its access must be.
The recommended kind: installed on specific repositories with fine-grained permissions, acting as themselves with short-lived installation tokens and receiving webhooks. Bots like Dependabot are GitHub Apps.
The older model that acts only as the signed-in user using broad scopes. Still fine for "Sign in with GitHub", but prefer GitHub Apps for anything that changes repositories.
Webhooks POST a JSON payload to your URL when events such as a push or a new issue happen. Verify the X-Hub-Signature-256 HMAC with your secret, respond quickly, and process the work asynchronously.
Free static hosting straight from a repository, at username.github.io or a custom domain. Good for docs, portfolios and project sites; anything needing a server belongs elsewhere.
Publish from a branch folder, or build with a GitHub Actions workflow using actions/upload-pages-artifact and actions/deploy-pages — the better choice for any build step.
Point a CNAME record (subdomain) or A/AAAA records (apex) at GitHub, set the domain in Pages settings, verify it to prevent takeovers, and enable HTTPS.
Pages builds Jekyll natively; Hugo, Astro, Eleventy, Docusaurus or a static Next.js export work through an Actions workflow that uploads the output folder.
GitHub's AI assistant: code completion and chat in editors, agent mode that edits several files, a coding agent that turns issues into pull requests, and AI code review. Treat its output like a colleague's pull request — read and test it.
Gists are tiny Git repositories for sharing snippets, notes or single files, public or secret (unlisted, not private). They can be cloned, forked and embedded, and gh gist create makes one from the terminal.
A catalogue of large language models from several providers that you can try in a playground, compare side by side and call through an API with a GitHub token. Handy for prototyping AI features before choosing a paid provider.
A package registry tied to your repositories and permissions, supporting npm, Maven, Gradle, NuGet, RubyGems and container images at ghcr.io. Publish from Actions using the built-in GITHUB_TOKEN.
A storefront for GitHub Apps and Actions — CI services, code-quality tools, security scanners — some free, some paid through GitHub billing. Check the permissions an app requests before installing it.
Cloud development environments that open a repository in VS Code (browser or desktop) within seconds. A .devcontainer/devcontainer.json defines the image, tools and extensions so every contributor gets the same setup.
Built-in protection for your supply chain: Dependabot alerts and update PRs, secret scanning with push protection, code scanning with CodeQL, and private vulnerability reporting through security advisories.
Lets people and companies fund open-source maintainers with one-time or monthly payments through GitHub. A FUNDING.yml in .github/ adds a Sponsor button to your repositories.
Programs that give students and teachers free tools and training. Verify your academic status once to unlock the benefits.
Free Copilot Pro and GitHub Pro for verified students, plus credits and licences from partner companies for cloud hosting, domains and developer tools.
Teachers create assignments that give each student a private repository from a template, with autograding through Actions and an overview of submissions.
Partnerships with schools that bundle GitHub Enterprise and teaching resources for whole institutions, alongside a student community program for campus leaders.