Domain 2: Working with GitHub Repositories (8%) โ
Creating and Managing Repositories โ
Creating a Repository โ
A repository can be created from:
- GitHub.com โ New repository button, with options for visibility, README, .gitignore, and license
- GitHub CLI โ
gh repo create - GitHub Desktop โ GUI wizard
- Template repository โ instantiate from an existing template
Key options when creating a repo:
| Option | What it does |
|---|---|
| Initialize with README | Creates a README.md on the default branch automatically |
| Add .gitignore | Pre-fills a .gitignore template for your language/framework |
| Choose a license | Adds a LICENSE file to define usage rights |
| Visibility | Public / Private / Internal |
Cloning vs Forking โ
| Action | What it does | When to use |
|---|---|---|
| Clone | Downloads the repo to your machine; you push to the same origin | You have write access |
| Fork | Creates your own copy of someone else's repo on GitHub | Contributing to repos you don't own |
Exam Tip
Fork โ clone โ PR is the standard open source contribution flow. Fork creates a copy on GitHub; clone downloads it locally; you submit changes via pull request back to the original.
Essential Repository Files โ
README.md โ
The README is the front page of your repository. GitHub renders it automatically on the repo homepage. Best practices:
- Project description and purpose
- Installation instructions
- Usage examples
- Contributing guidelines
- License information
LICENSE โ
Without a license, code is "All Rights Reserved" by default โ others legally cannot use, copy, or distribute it. Common licenses:
| License | Permissions | Requirements |
|---|---|---|
| MIT | Use, copy, modify, distribute | Keep copyright notice |
| Apache 2.0 | Use, copy, modify, distribute | Keep copyright + patent notice |
| GPL v3 | Use, copy, modify, distribute | Derivative works must also be GPL |
| Creative Commons | Varies | For creative work, not code |
GitHub Tip
GitHub's license picker is available when creating a repo. You can also add a LICENSE file at any time and GitHub will recognize and display it.
.gitignore โ
Tells Git which files and directories to ignore (not track). Common patterns:
# Dependencies
node_modules/
vendor/
# Build output
dist/
*.class
# Environment files
.env
.env.local
# OS files
.DS_Store
Thumbs.dbGitHub provides .gitignore templates for popular languages and frameworks when creating a repo.
CODEOWNERS โ
The CODEOWNERS file (in root, docs/, or .github/) automatically assigns reviewers to pull requests based on file patterns:
# Global owner
* @org/team-leads
# Frontend files
*.js @org/frontend-team
# Docs
docs/ @org/technical-writersExam Note
CODEOWNERS can be placed in three locations: repo root, docs/, or .github/. Only the first matching CODEOWNERS file is used. Code owners are automatically requested for review when files they own are changed in a PR.
Releases and Tags โ
Tags โ
A tag marks a specific commit in history โ typically used to mark release versions. Two types:
| Type | Description |
|---|---|
| Lightweight tag | A pointer to a commit (like a branch, but doesn't move) |
| Annotated tag | Stores metadata: tagger, date, message. Recommended for releases. |
git tag v1.0.0 # lightweight
git tag -a v1.0.0 -m "First release" # annotated
git push origin v1.0.0 # push specific tag
git push origin --tags # push all tagsReleases โ
A GitHub Release is built on top of a tag and adds:
- Release title and description (supports Markdown)
- Attached binary assets (downloads)
- "Latest release" badge
- Auto-generated release notes from merged PRs
Exam Tip
Tags exist in Git. Releases exist in GitHub. You can create a Release from an existing tag, or GitHub creates the tag when you publish a Release.
Template Repositories โ
A template repository lets teams create new repos pre-populated with a standard structure (files, folders, workflows, etc.) โ without inheriting the full commit history.
- Enable via: Repository Settings โ check "Template repository"
- Users click "Use this template" instead of forking or cloning
- Common uses: project boilerplates, org standards, documentation sites
| Feature | Template | Fork |
|---|---|---|
| Gets commit history | โ No | โ Yes |
| Linked to original | โ No | โ Yes (can PR back) |
| Purpose | Fresh start with structure | Contribute or customize |
GitHub Pages โ
GitHub Pages hosts static websites directly from a repository (free for public repos):
- Source can be:
mainbranch root,main/docs/, or a dedicatedgh-pagesbranch - URL format:
https://username.github.io/repo-name/ - Supports Jekyll for static site generation
- Custom domains supported
Domain 2: Repository Management
What is the difference between cloning and forking a repository?
(Click to reveal)