Introduction
As someone who has always struggled to understand the purpose and usage of Git and GitHub, I know the hassle when you are just starting in Development, and everyone around you is using fancy terms like 'PR', 'PUSH', 'COMMIT', although these are very easy to understand.
We sometimes struggle to figure out the logic behind them, but after reading this blog, I am sure you'll be able to not only understand Git and GitHub but also implement and manage your projects through it.
Introduction to Git and GitHub for Beginners
Git is a version control system that helps developers manage their codebase, while GitHub is an online platform that hosts Git repositories and enables collaboration among developers.
What is Git?
Git is a distributed version control system that enables developers to track changes to their codebase and collaborate with others. It was created by Linus Torvalds, the creator of Linux, in 2005, and has since become one of the most popular version control systems in use today. Git is designed to be fast, efficient, and scalable, and can handle both small and large codebases with ease.
Let's understand Git with a simple example:
Let's say you have a car, you want to modify some of the features and make changes in your car. But after you make the needed changes, you are not satisfied with the result and want to revert to the past version, what will you do?
If it was a permanent change, there's no way of going back, but if it is temporary, you could revert to the version before.
The same logic applies to coding, Git lets us manage different versions of our code, website, or app which we are building. You can control different modifications made by different people to the same codebase and product.
That's exactly what Git does, and GitHub is just a tool to manage such codebases and deliver a good UI to manage the same.
At its core, Git is a command-line tool that enables developers to create repositories, track changes, and collaborate with others. It uses a decentralized model, which means that each developer has a local copy of the codebase and can work on it independently. Changes can then be merged using Git's powerful merge and conflict resolution tools.
Now let us see what GitHub is at its core.
What is GitHub?
GitHub is an online platform that hosts Git repositories and enables collaboration among developers. It was founded in 2008 and has since become the largest host of source code in the world, with over 100 million repositories and millions of users. GitHub provides a range of features, including project management tools, issue tracking, code review, and continuous integration and deployment.
One of the key benefits of using GitHub is that it enables developers to collaborate with others on their codebase. This can include working on the same codebase simultaneously, sharing code snippets, reviewing each other's code, and more. GitHub also provides a range of social features, including the ability to follow other developers, star their repositories, and discover new projects.
Getting Started with Git and GitHub
If you're new to Git and GitHub, getting started can seem daunting at first. However, with a little practice and guidance, you can quickly become comfortable with these powerful tools. Here are the basic steps to getting started with Git and GitHub:
Install Git: The first step is to install Git on your local machine. Git is available for Windows, macOS, and Linux, and can be downloaded from the official Git website. Once installed, you can use Git via the command line or through a graphical user interface (GUI).
Set up a GitHub account: The next step is to set up a GitHub account. This is free and easy to do, and only requires an email address and a username. Once you've created your account, you can create and manage repositories, collaborate with others, and discover new projects.
Create a repository: Once you've set up Git and GitHub, the next step is to create a repository. This can be done via the command line or through the GitHub website. To create a repository via the website, simply click the "New" button in the top left corner, and follow the prompts to set up your repository.
Add files and commit changes: With your repository set up, the next step is to add files and commit changes. This is done via Git's command-line tool or through a GUI. To add files, simply use the "git add" command, followed by the filename. To commit changes, use the "git commit" command, followed by a message describing the changes.
Push changes to GitHub: Once you've committed your changes, the final step is to push them to GitHub. This is done via the "git push" command, which uploads your changes to the remote repository on GitHub. From there, you
Some git commands you should know
git init
This command creates a new git repository and it is usually one of the first things you do when starting a new project.
git status
Get the status of a branch.
git commit -m "commit message"
Commit to the main branch, including a commit message.
git clone <repository-url>
Clone a repository, by including the repository URL.
git pull <remote>
Pull changes from a remote repository.
git merge branch-name
merge changes from a different.
Conclusion
This blog was an attempt to make you understand the crisp of Git in coordination with GitHub and how you can use them both to manage your projects and work with others in collaboration.
In my experience, it was moderately tough to understand Git and GitHub in the beginning, especially getting used to the UI and functionality of GitHub, but once I started creating my repos, and adding and uploading files and code on GitHub, it gets pretty easy.
I started my Open Source project 'Dealing with Javascript' and it has got over 20 starts currently, I would love it if you could check it out and collaborate with me on making this project huge!
That was all for this blog, I will be back again next Sunday at 9:30 am!