GitHub Guide for Students
Introduction
GitHub is a platform that enables developers to collaborate on projects, manage versions of their code, and share their work with the world. This booklet will introduce you to the essential concepts, terminology, and features of GitHub. By the end, you'll be familiar with the GitHub UI and equipped to use GitHub effectively without running into blockers.
Glossary of Terms
Repository (Repo)
A storage location for your project files and their version history. On GitHub, a repository is where your project lives.
Branch
A parallel version of your repository. The default branch is usually called main or master.
Commit
A snapshot of changes in your project. Commits form the history of your repository.
Pull Request (PR)
A request to merge changes from one branch into another. PRs are essential for code reviews and collaboration.
Fork
A personal copy of another user's repository. Forking allows you to experiment without affecting the original project.
Clone
A local copy of a repository that you can work on. Cloning allows you to work offline and sync your changes later.
Push
Uploading local changes to a remote repository on GitHub.
Pull
Fetching and integrating changes from a remote repository into your local copy.
Issue
A way to track bugs, enhancements, or other tasks related to your project.
Milestone
A collection of issues and pull requests associated with a specific goal or deadline.
Wiki
A space within your repository where you can write and store documentation.
Actions
Automated workflows that you can configure to build, test, and deploy your code.
GitHub UI Overview
Home Page
-
Repositories: Access your repositories or create a new one.
-
Pull Requests: View, create, and manage pull requests.
-
Issues: Track and manage issues for your repositories.
-
Actions: Set up and monitor automated workflows.
-
Projects: Organize and prioritize your work with project boards.
Repository Page
-
Code: Browse the code files in the repository.
-
Issues: Create and manage issues related to the repository.
-
Pull Requests: View and merge pull requests.
-
Actions: Monitor workflow runs and configure actions.
-
Projects: Access project boards for the repository.
-
Wiki: View or edit the repository's wiki.
-
Settings: Configure repository settings, including access control and integrations.
Getting Started with GitHub
1. Creating a Repository
-
Click the + icon in the top-right corner and select "New repository."
-
Fill in the repository name and description.
-
Choose the visibility (public or private) and initialize with a README if desired.
-
Click "Create repository."
2. Cloning a Repository
-
Navigate to the repository page.
-
Click the "Code" button and copy the URL.
-
In your terminal, run : git clone https://github.com/username/repository.git
3. Making Changes and Committing
-
Make changes to your files locally.
-
Stage your changes : git add filename
-
Commit your changes: git commit -m "Commit message"
4. Pushing Changes
- Push your changes to GitHub: git push origin branch-name
5. Creating a Branch
-
Create and switch to a new branch: git checkout -b branch-name
6. Creating a Pull Request
-
Push your branch to GitHub.
-
Go to the repository page on GitHub.
-
Click the "Pull requests" tab and then "New pull request."
-
Select your branch and follow the prompts to create the PR.
7. Merging a Pull Request
-
Review the changes in the PR.
-
If everything looks good, click "Merge pull request."
-
Confirm the merge.
8. Managing Issues
-
Go to the "Issues" tab in your repository.
-
Click "New issue" and fill in the details.
-
Assign labels, milestones, and assignees as needed.
9. Using Projects
-
Go to the "Projects" tab and click "New project."
-
Create a project board to organize your tasks and issues.
-
Add cards to the board for issues, pull requests, or notes.
10. Setting Up Actions
-
Go to the "Actions" tab in your repository.
-
Click "New workflow" and choose a template or create a custom workflow.
-
Define the actions and triggers in the workflow file.
Tips for Using GitHub Effectively
-
Keep Your Commits Small and Focused: This makes it easier to understand and review changes.
-
Write Descriptive Commit Messages: Clear messages help you and others understand the purpose of changes.
-
Use Branches for Features and Fixes: Isolate work in branches to keep the main branch stable.
-
Regularly Pull Changes from the Remote Repository: Stay up-to-date with the latest changes to avoid conflicts.
-
Review Pull Requests Thoroughly: Ensure code quality and catch potential issues early.
-
Utilize Issues and Projects: Keep your work organized and track progress effectively.
Conclusion
GitHub is a powerful platform that facilitates collaboration and version control. By understanding the terminology, familiarizing yourself with the UI, and following the outlined workflows, you'll be well-equipped to use GitHub effectively in your projects. Happy coding!