Git & GitHub Essentials: Part 1 - The Foundation

In this complete airtcle you will understand all the basic things about Git and GitHub and it is just a part one of series Master Git and GitHub

·

6 min read

Guide to Version Control and Collaborative Development from complete zero

Before diving into the depths of Git and GitHub, we have to answer some fundamental questions. Which is in the three phases:

  1. What are Git and GitHub?

  2. Why do we need to use Git and GitHub?

  3. How can we have to use Git and GitHub?

What are Git and GitHub?

Before understanding Git and GitHub, we have to know some common terminologies and they are

  1. GUI (Graphical User Interface): Simply put, it is known as File Explorer in Windows or Finder, and it provides you with a graphical interface to work with the files that are accessible on your hard drive. You can relocate, rename, move, and delete files with its assistance.

    This is how File Explorer or Finder look like

    Given that you can interact with your files here and they have colour, images, and shapes, you can see them.

  2. CLI (Command Line Interface): On our programming or developer journey, we will use this most basic type of file explorer. Then, you might be questioning how CLI differs from GUI and why we need to learn a new one if they are both the same. Why do we need to utilize or learn about CLI when Windows already offers a lovely user interface?

    Let's address each of your inquiries one at a time:

    The CLI is a file explorer as well, but it is more powerful.

    Attempt to comprehend this using an illustration Imagine there is a folder called FolderOne on your desktop, and within FolderOne, there is a folder called data, and inside of that, there is a folder called "Collected Data," and inside of Collected Data, there is a file named Hello.txt, and its path is as follows:

    "hello.txt" is located in FolderOne/Data/Collected Data.

    You now have two options for accessing that file.

    First, the GUI has already made you aware of it.

    Second, allow me to demonstrate using the CLI. Open CLI, a different process in a different operating system,

    After starting the CLI, write directly "FolderOne/Data/Collected Data/," and you will be immediately inside the folder containing the real data, which is hello.txt. Simply type "open -a" to open that file in the built-in text editor. If you want to return to where you first started, just type "cd <space> ~," You are immediately returned to your default location, and yeah, don't worry about memorizing every command. The more you use them, the more you remember them. That concludes this. I know at first this looks difficult, but the more you do it, the more comfortable you become with it, and consider the fact that throughout the entire procedure, you don't have to use your mouse while using CLI.

    Conclusion: Most developers and programmers use the CLI just because it has more power than your GUI because it talks directly with your kernel and can do long tasks in seconds with less hard work, whereas with the GUI you can do some tasks but not as short as the CLI does.

Let us discuss GitHub and Git now. Git is a tool that we have to install inside our local machine; it is more like software, and GitHub is a website from where we can operate practically everything with ease. So you might be thinking, then, why do we use it? The process becomes tedious when you go to your browser, go to your particular repository, and make the particular changes, but with the help of git, it is easier to make the particular changes and update those things in those particular instances.

Now let's understand a bit further Let's suppose you are working on a particular project and have made a few changes there. Now you want to reflect these changes in your repository so you have two ways to do that

Method 1: By Simply going to your browser, then Github, and then your target repository and uploading changes manually, think about how tedious the normal work is going to be.

Method 2: The Second way of uploading those same files with changes is through the terminal by simply writing these commands

  1.   git add .
    
  2.   git commit -m "About changes that you made"
    
  3.   git remote add origin <url>
    
  4.   git push -u origin main
    

Don't worry if you don't understand the four commands that were written over here; I will cover these in the upcoming blogs. I have to write this because I wanted to explain this to you. This is much more efficient than manually uploading every file where you made changes.

I hope you get clarity on why everyone is saying if you are a developer and programmer, then you have to learn about Git and GitHub. I hope that makes sense to you. If you have any feedback or messages, you can reach out to me on my social media handles.

Why do we need to use git and Github?

Well, some of the portion I will already cover under the previous heading is quite simple to understand, but here is a deeper explanation of why we need to use git and GitHub.

Let's suppose you are working for a company remotely and they assign you to change and update their project code-base while working from your home There are two ways through which you can do the work

First: You ask them to send the code base in zip format, then you start working on it and fix some errors and bugs in the code base and then you zip all the code-base files and send them back to them with some updates Now the most difficult part is in front of you, you have to explain what changes you made and where, and imagine if that code base contains thousands of lines. What will you do?

You face these issues

  1. Every time you have to change or update something in the code base, you have to unzip it first to make changes and then zip it again to send it back to them.

  2. If you made a few changes in the code base, you have to explain to them what changes you made and, most importantly, where you made those changes if your code base contains thousands of lines. and it was more difficult if on that same code base, many people were working

Now, Let's talk about how Git and GitHub help you do it with less effort

  1. Instead of sending code base from person to person, upload that code base on GitHub and then assign as many people as you can to work on that code base This time, let's suppose you assign four people to a particular code base If any one person made few changes in the code base, then everyone can see that changes while highlighting those changes, as shown below

As you can see, this red line indicates that these lines were deleted or changed. With the text that is shown in the green line, this is how you can see a particular change in a large code base if it is a 2000-line code base. You will also see a lot of other details, like who made this change, why he made it, and when he made it, which I will discuss with you in the upcoming blogs.

How can we have to use Git and GitHub?

First, you have to install git on your local machine. You can search git bash on Google and get this link:

and create a GitHub account, and you are good to go. Okay, that's it for today. If you have any suggestions for me, please let me know You can tell me on my social media handles Also, thank you for reading If you find it helpful, share for good karma✌️

Did you find this article valuable?

Support Bedi Gupta by becoming a sponsor. Any amount is appreciated!