Table of contents
- 1. Explaining Git to a Ten-year-old 🤓
- 2. Understanding Repositories🤓
- 3. All About Commits🤓
- 4. Introducing GitHub🤓
- 5. Pushing Your Code to GitHub🤓
- 6. Domain Names🤓
- 7. Servers🤓
- 8. Website Hosting🤓
- 9. Clients🤓
- 10. Hosting Your Website Online🤓
- 11. Main Branch and Other Branches🤓
- 12. Pull Requests (PR)🤓
- 13. Pull and Push🤓
Welcome to this beginner's guide to Git and GitHub! In this article, we'll cover some basic fundamentals to help you understand these essential tools for version control and collaborative software development.
1. Explaining Git to a Ten-year-old 🤓
👉Imagine Git as a magical bookkeeper that keeps track of changes made to your code. It records who made the changes, when they were made, and what exactly was changed. Just like how humans can make mistakes, computers can too. Git allows you to go back to a previous version of your code, like turning back the pages of a book, to fix any issues or mistakes.
👉In simple terms, Git is a change tracking mechanism for your code.
2. Understanding Repositories🤓
👉A repository is like a folder or container that holds all your source files and programming content. It's a centralized place where you organize and manage your codebase.
👉Remember these key points about changes in your code:
Green color: Indicates additions or new code.
Red color: Represents deletions or removed code.
+ symbol: Denotes a file that has been added to the repository.
3. All About Commits🤓
👉A commit is like saving your progress in a game. When you make changes to your code, you create a commit to record those changes. A commit is accompanied by a commit message, which describes the purpose or nature of the changes you made.
👉Here are some examples of good commit messages:
feat: Introduces a new feature.
fix: Addresses a bug or issue.
docs: Updates or adds documentation.
style: Refactors code related to styling or formatting.
refactor: Modifies code without adding new features or fixing bugs.
test: Adds or modifies tests.
chore: Updates build tasks, package manager configurations, etc.
👉For instance:
Commit message: DOCS: Added readme file
Commit message: FIX: Validating input for leap year
Commit message: STYLE: Used chalk to beautify CLI app
Commit message: FEAT: Added level-based gameplay
Commit message: REFACTOR: Changed variable name from
var a
tovar questions
👉Remember, writing descriptive commit messages helps you and your team understand the changes made at a glance.
4. Introducing GitHub🤓
👉Up until now, your repository only exists on your local machine. GitHub is a cloud-based platform where you can store your code, making it accessible to others. GitHub allows people to view, contribute to, collaborate on, and enhance your code. It is a central hub for open-source projects and facilitates seamless teamwork.
👉In simple terms, Git is used locally on your machine, while GitHub is the platform where you share your code with others.
5. Pushing Your Code to GitHub🤓
👉Once you have committed your changes and written a descriptive commit message, the next step is to push your code to your branch on GitHub. This action uploads your local changes to your GitHub repository, making them available for others to see and collaborate on.
6. Domain Names🤓
👉Domain names are the unique addresses used to identify websites on the internet. Every website has its own domain name, which acts as its online identity.
7. Servers🤓
👉Servers play a crucial role in hosting websites and managing domain names. Two important concepts related to servers are:
Name Server: It maps domain names to their corresponding server addresses. When you provide a domain name, the name server provides you with the server address associated with that domain.
Web Server: This server serves the files of a website to clients, such as your browser or mobile browser.
8. Website Hosting🤓
👉Website hosting involves keeping the files of a website on a server. Hosting is essential to make your website accessible to others. There are various hosting providers available, with Netlify being a highly recommended option.
9. Clients🤓
👉Clients refer to the devices or software that access and request information from servers. Examples of clients include web browsers on laptops and mobile devices.
10. Hosting Your Website Online🤓
👉To make your website available to the public, you need to host it online. There are several hosting options, but Netlify is often the top choice due to its user-friendly interface and seamless deployment process.
11. Main Branch and Other Branches🤓
👉Think of branches as divergences from the main road. In Git, there is typically a main branch (often called "master" or "main") where the stable and production-ready code resides. When you create a new branch, it serves as a separate path for implementing new features or making changes. Once you're satisfied with the changes in your branch, you merge it back into the main branch.
👉It's important to note that until you merge your branch into the main branch, the changes you make won't be visible on the online hosted website. Only the content of the main branch will be visible to the public.
12. Pull Requests (PR)🤓
👉Pull requests are a way to propose changes from one branch to another, typically from a feature branch to the main branch. They allow team members to review the changes, provide feedback, and eventually merge the code into the main branch. Pull requests often include a preview feature, allowing you to see how the changes will look once merged.
👉Pull requests are particularly helpful when working in a team and ensuring code quality and collaboration.
13. Pull and Push🤓
👉In Git, pull refers to fetching changes from a remote repository (e.g., GitHub) to your local repository. It brings the latest changes to your local machine.
👉On the other hand, push is the action of sending your local commits to the remote repository. This action updates the repository on GitHub with your latest changes.
👉Understanding the distinction between pull and push is essential when collaborating on a project with multiple contributors.
👉By grasping these fundamentals, you'll be well on your way to establishing your presence on GitHub and effectively managing your codebase.
If you liked my content, How about connecting with me?