Exercise: Introduction To GitHub
Introduction to GitHub

Welcome to Your Skills Exercise!
👋 Hey there Ashan-KPR! Welcome to your Skills exercise! If you are new to GitHub, you might find your fellow developers use issues to organize their work and collaborate. We will do the same! That's another lesson, but today, we will introduce you to the basics.
What is GitHub?
GitHub is a web-based platform for version control and collaboration on software development projects. It allows developers to store and manage their code in a centralized repository, making it easier to collaborate with others and track changes to the codebase. GitHub provides a range of features, including:
- Version control: GitHub allows developers to track changes to their codebase over time, making it easier to identify and fix errors.
- Collaboration: GitHub enables multiple developers to work on the same project simultaneously, making it easier to collaborate and share code.
- Open-source: GitHub provides a platform for open-source projects, allowing developers to share their code with the community and receive feedback and contributions.
Creating a GitHub Account
To get started with GitHub, you need to create a GitHub account. Here's how:
- Go to the GitHub website (www.github.com) and click on the "Sign up" button.
- Enter your email address, username, and password.
- Fill out the required information, including your name and location.
- Click on the "Create account" button.
Creating a New Repository
Once you have created a GitHub account, you can create a new repository. Here's how:
- Log in to your GitHub account.
- Click on the "+" button in the top-right corner of the screen.
- Select "New repository" from the dropdown menu.
- Enter a name for your repository and a brief description.
- Choose a license for your repository (optional).
- Click on the "Create repository" button.
Understanding Repository Structure
A GitHub repository typically consists of the following files and directories:
- README.md: A file that provides an overview of the project, including its purpose, features, and usage instructions.
- LICENSE: A file that specifies the license under which the project is released.
- src: A directory that contains the source code for the project.
- tests: A directory that contains test files for the project.
- docs: A directory that contains documentation for the project.
Committing Changes
When you make changes to your code, you need to commit those changes to the repository. Here's how:
- Make changes to your code.
- Open the terminal and navigate to the repository directory.
- Run the command
git add .
to stage the changes. - Run the command
git commit -m "Commit message"
to commit the changes. - Push the changes to the remote repository using the command
git push origin master
.
Pulling Changes
When you want to retrieve changes from the remote repository, you need to those changes. Here's how:
- Open the terminal and navigate to the repository directory.
- Run the command
git pull origin master
to retrieve the changes.
Collaborating with Others
GitHub provides a range of features that make it easy to collaborate with others. Here are a few:
- Forking: You can fork a repository to create a copy of it, making it easier to collaborate with others.
- Pull requests: You can create a pull request to request changes to the original repository.
- Issues: You can create issues to track bugs or feature requests.
Conclusion
In this exercise, we introduced you to the basics of GitHub, including creating a GitHub account, creating a new repository, understanding repository structure, committing changes, pulling changes, and collaborating with others. We hope this exercise has provided you with a solid foundation for working with GitHub.
What's Next?
In the next exercise, we will cover more advanced topics, including:
- Branching and merging: We will cover how to create and manage branches, as well as how to merge changes from one branch to another.
- GitHub Actions: We will cover how to use GitHub Actions to automate tasks and workflows.
- GitHub Pages: We will cover how to use GitHub Pages to host a website or blog.
Additional Resources
If you want to learn more about GitHub, here are some additional resources:
- GitHub documentation: The official GitHub documentation provides a comprehensive guide to using GitHub.
- GitHub tutorials: GitHub provides a range of tutorials that cover various topics, including getting started with GitHub, using GitHub for collaboration, and using GitHub for open-source projects.
- GitHub community: The GitHub community is a great place to connect with other developers and get help with any questions you may have.
Task: Commit changes to the repository.
Instructions:
- Make changes to the code.
- Open the terminal and navigate to the repository directory.
- Run the command
git add .
to stage the changes. - Run the command
git commit -m "Commit message"
to commit the changes. - Push the changes to the remote repository using the command
git push origin master
.
Task: Pull changes from the remote repository.
Instructions:
- Open the terminal and navigate to the repository directory.
- Run the command
git pull origin master
to retrieve the changes.
Task: Collaborate with others on the repository.
Instructions:
- Fork the repository to create a copy of it.
- Create a pull request to request changes to the original repository.
- Create issues to track bugs or feature requests.
Conclusion
Introduction
GitHub is a web-based platform for version control and collaboration on software development projects. It allows developers to store and manage their code in a centralized repository, making it easier to collaborate with others and track changes to the codebase. In this article, we will answer some frequently asked questions about GitHub.
Q: What is GitHub?
A: GitHub is a web-based platform for version control and collaboration on software development projects. It allows developers to store and manage their code in a centralized repository, making it easier to collaborate with others and track changes to the codebase.
Q: What is the difference between GitHub and Git?
A: Git is a version control system that allows developers to track changes to their codebase. GitHub is a web-based platform that provides a centralized repository for Git, making it easier to collaborate with others and track changes to the codebase.
Q: How do I create a GitHub account?
A: To create a GitHub account, follow these steps:
- Go to the GitHub website (www.github.com) and click on the "Sign up" button.
- Enter your email address, username, and password.
- Fill out the required information, including your name and location.
- Click on the "Create account" button.
Q: How do I create a new repository on GitHub?
A: To create a new repository on GitHub, follow these steps:
- Log in to your GitHub account.
- Click on the "+" button in the top-right corner of the screen.
- Select "New repository" from the dropdown menu.
- Enter a name for your repository and a brief description.
- Choose a license for your repository (optional).
- Click on the "Create repository" button.
Q: What is the difference between a fork and a clone?
A: A fork is a copy of a repository that is created by a user. A clone is a copy of a repository that is created by a user, but it is not a fork. When you fork a repository, you create a new repository that is a copy of the original repository. When you clone a repository, you create a copy of the repository on your local machine.
Q: How do I create a pull request on GitHub?
A: To create a pull request on GitHub, follow these steps:
- Log in to your GitHub account.
- Navigate to the repository that you want to create a pull request for.
- Click on the "New pull request" button.
- Select the branch that you want to create a pull request for.
- Enter a title and description for the pull request.
- Click on the "Create pull request" button.
Q: What is the difference between a branch and a tag?
A: A branch is a separate line of development in a repository. A tag is a snapshot of a repository at a specific point in time. When you create a branch, you create a new line of development that is separate from the main branch. When you create a tag, you create a snapshot of the repository at a specific point in time.
Q: How do I merge a branch into the main branch on GitHub?
A: To merge a branch into the main branch on GitHub, follow these steps:
- Log in to your GitHub account.
- Navigate to the repository that you want to merge a branch into.
- Click on the "Merge" button.
- Select the branch that you want to merge into the main branch.
- Click on the "Merge" button.
Q: What is GitHub Pages?
A: GitHub Pages is a feature of GitHub that allows you to host a website or blog on GitHub. You can create a GitHub Pages site by creating a new repository and selecting the "GitHub Pages" option.
Q: How do I create a GitHub Pages site?
A: To create a GitHub Pages site, follow these steps:
- Log in to your GitHub account.
- Create a new repository.
- Select the "GitHub Pages" option.
- Enter a title and description for your site.
- Click on the "Create site" button.
Conclusion
In this article, we answered some frequently asked questions about GitHub. We hope this article has provided you with a better understanding of GitHub and its features. If you have any further questions, please don't hesitate to ask.