GitHub Tutorial
- 1. Introduction to GitHub
- 2. Account Setup & SSH
- 3. Repository Management
- 4. Remotes & Syncing
- 5. Collaborating Via Branches
- 6. Forking & Pull Requests
- 7. Code Reviews & Branch Protection
- 8. Merge Strategies
- 9. Issues & Projects
- 10. Markdown & Project Wikis
- 11. Deploying to GitHub Pages
- 12. CI/CD with GitHub Actions
- 13. Packages & Releases
- 14. Gists & Discussions
- 15. Security & Dependabot
3. Repository Management
The fundamental building block of GitHub is the **Repository** (often shortened to "Repo"). A repository houses all of your project files, assets, folders, and most importantly, the entire Git commit history. In this chapter, we will learn how to create and manage repositories effectively.
1. Creating a New Repository on GitHub
- Go to github.com and log in.
- Click the **"+"** drop-down menu in the top-right corner, and select "New repository".
- Fill in the repo settings:
- Repository name: Keep it short, descriptive, and lowercase, separating words with hyphens (e.g.,
portfolio-website). - Description (Optional): A brief summary of what the project is.
- Repository name: Keep it short, descriptive, and lowercase, separating words with hyphens (e.g.,
2. Repository Visibility: Public vs. Private
| Visibility | Who can view? | Who can write/commit? | Best Use Case |
|---|---|---|---|
| Public Repository | Anyone on the internet can see it, search for it, and fork it. | Only you and designated contributors who have write permissions. | Open-source projects, personal portfolios, learning repositories. |
| Private Repository | Only you and specific collaborators you explicitly invite. | Only you and invited collaborators. | Commercial applications, homework/assignments, proprietary business code. |
3. Initializing Your Repository
When creating a repo, GitHub gives you options to automatically initialize it with three vital files:
A. README.md
A markdown file containing a description of the project, how to install dependencies, run code, and contribute. GitHub automatically displays this file's rendered contents directly on your repository's homepage!
B. .gitignore Templates
You can tell GitHub to automatically pre-fill a .gitignore file for you based on the language or framework you are using (e.g., Node.js, Python, Java, or Unity). This ensures log files and node folders are kept out of tracking immediately.
C. Choosing a License
A software license tells the public what they can and cannot do with your source code. If you do not choose a license, the default copyright laws apply, meaning no one can copy, distribute, or modify your work. Common open-source license templates provided by GitHub:
- MIT License: Extremely permissive. People can do almost anything they want with your code, including commercializing it, as long as they attribute credit to you.
- Apache License 2.0: Similar to MIT, but provides patent protection and requires developers to list modifications.
- GNU GPL v3: A "copyleft" license. Anyone who modifies your code and releases it to the public **must also open-source their modified code** under the same GPL v3 license.
4. Managing Repository Settings
Once a repository is created, clicking the Settings tab in the top navigation panel gives you access to admin controls:
- Collaborators: Invite other developers to contribute to your repository by entering their GitHub username or email.
- Rename Repository: Change your project name (GitHub will automatically redirect requests from the old URL to the new one).
- Danger Zone: Located at the absolute bottom of settings, this is where you can change visibility (Public to Private), transfer ownership to another account/org, or **permanently delete the repository**.