Layman’s Guide to Git and GitHub:


Introduction
Imagine you’re writing a book with friends. Each person is working on different chapters, and you need to keep track of everyone’s changes without getting confused. This is where Git and GitHub come in handy. Git is like a super organized notebook for keeping track of all the changes, and GitHub is like an online library where you and your friends can store and share your work.
Let's see What is Git and Git Hub in detail
What is Git ?
Git is a distributed version control system that helps you keep track of changes in your projects, especially when working with others. Let's see how Git work's using the above mentioned example:
Version Control: Git helps you keep track of every change made to your book. You can always go back and see who changed what and when. Similarly, when you use Git for your projects, you can see who changed the code or content in the repository and when they changed it.
Branching and Merging: Imagine each friend writes their own chapter on a separate page (branch). When the chapters are ready, you combine them into the final book (merge). Similarly, in projects, each person develops their code on their own branch, which is separate from the main branch. Finally, if there are no errors in their code, it is merged into the main branch.
Commit History: Git keeps a record of all changes, like a diary where you write down what you changed and why. As I mentioned, it stores everything that developers do to the repository.
All these Git repositories have to be stored somewhere, and that's when GitHub comes in.
What is Git Hub ?
GitHub is an online platform where you can store your Git projects and collaborate with others. Think of GitHub as a giant bookshelf in the cloud where everyone can access and work on the book together. let's see the key offerings of Git Hub
Repositories: A repository (repo) is a central location where all the files, folders, and version history related to a project are stored. It serves as a container for organizing, tracking changes, and collaborating on code and project files.
Pull Requests: If someone wants to add a new chapter or make changes, they create a pull request. It’s like asking permission to add their pages to the book. Similarly, if anyone wants to contribute, add something to the project, or make any changes to it, they will create a pull request.
Issues: These are like sticky notes for problems or suggestions, such as fixing a typo or adding a new character.
Setting Up Git and GitHub
To start using Git and GitHub, follow these steps:
Install Git: Download and install Git from git-scm.com.
It’s like getting the notebook you’ll use for your project.
Create a GitHub Account: Sign up at github.com.
This is like joining the online library where you’ll store your book.
Set Up a Repository: On GitHub, create a new repository for your project.
This is where you’ll keep all your chapters and changes.
Basic Git Commands
Here are some basic Git commands to get you started, with our book analogy:
Initializing a Repository:
git init
– Start a new notebook for your book.Cloning a Repository:
git clone <repository_url>
– Get a copy of the book from the library to your desk.Adding Changes:
git add <file_or_directory>
– Add new pages (changes) to your notebook.Committing Changes:
git commit -m "Your commit message"
– Write a diary entry about what you changed in the book.Pushing Changes:
git push
– Send your changes from your notebook to the library shelf.Pulling Changes:
git pull
– Get the latest version of the book from the library to your desk.
Let's talk about these commands in detail in the upcoming blogs.
Collaboration with GitHub
GitHub makes collaboration easy. Here’s how you can work with others:
Forking Repositories: Create your own copy of someone else’s project.
Creating Branches: Work on new features or fixes without affecting the main codebase.
Making Pull Requests: Propose your changes to the original project.
Reviewing and Merging Pull Requests: Discuss, review, and merge changes from other collaborators.
Real World Example - VS Code
Visual Studio Code, developed by Microsoft, is an open-source code editor. Its source code is hosted on GitHub, where developers from around the world contribute by submitting pull requests, reporting issues, and discussing new features. The collaborative nature of GitHub allows for rapid development and integration of community contributions.
link - https://github.com/microsoft/vscode
Conclusion
In the world of software development, keeping track of changes and collaborating effectively is crucial. Git and GitHub are powerful tools that can greatly improve your development workflow and collaboration. By understanding and using these tools, you can manage your projects more effectively and work seamlessly with others. Start exploring Git and GitHub today and see how they can benefit your projects!
Subscribe to my newsletter
Read articles from shiva kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
