Beginner and Confused about Git & GitHub? Then this is what you need!

Anwesha Sanyal
4 min readAug 10, 2021

What is Git?

The most widely used version control system is Git. It was developed to work with several developers on the Linux kernel in 2005.

Git is designed so that multiple developers can work on real-life projects together. It provides features like forking, merging, cloning, etc. Getting confused by all these terms? No worries! We’ll have a clear discussion on these.

So ultimately you can think Git as a collection of tired containers. Here you can store your piece of code, anytime you can access any piece of your stored code and use it accordingly and share it with others.

displays how git works
displays how Git works

How Git Works?

“Distributed is the new centralized”- that’s where Git comes into the frame. Git is an example of Distributed Version Control System(DVCS). So, in Git every developer works on a copy of the code that’s called repository and it contains all the changes that have been made on the code piece. That’s why it’s important to understand and create a repository while getting started with Git.

Repositories are like those tired containers. Here we can store multiple work files. To use these repositories we should host these at first. Now, this hosting can be done online(on the cloud using GitHub, GitLab, etc) and offline(on the self-installed server).

At first, we start with our work directory from there we can initialize Git and add our files to the staging area. Then after committing we’re done with hosting our repository locally. After that host that in a remote repository as well. Felt overwhelmed? Hold on we’ll discuss all these more clearly!

Here we’ll see how to host a repository(repo) offline and on GitHub.

What is GitHub? Are Git and GitHub the same?

GitHub and Git are as same as the words- child and childishness. Now you must be wondering what does that statement mean? Well just as childishness is something meant for every child, the same way GitHub is designed to host every Git repository on the cloud base. What does even that hosting on the cloud mean? It’s like putting our piece of code each time to an online database that allows us to keep track of each and every change made on it and to share that as well. We can use Git as a time travel option to go back in time and get our previous code versions(that’s what we call version controlling). GitHub helps to do the same along with that it makes the sharing process much easier so that other developers too can easily contribute to the code for betterment. So the power of Git that used to be restricted only in our local systems, GitHub empowered that to be globally available.

difference between Git & GitHub

Getting Started with Git!

Phew! after a long theoretical let’s get into hands-on practice and see how to get started with Git. It’s free and open-source so you can easily go and download Git to your system.

Before initializing Git, don't forget to be in the project directory.

from here you can initialize Git- by using git init

how to initialize Git

as you’ve initialized Git, it’s like you’ve bought the tired container. Now you can put your files into it. To do so, there’s a command git add . , it’ll add all your files to the repository else you can write the specific file name that you want to add like- git add file1.cpp

adding all the files to the repo

Adding isn’t enough though. You may have to travel back to this stage and see what you had done then. So won’t it be better to place a timestamp here to remind yourself later on? That’s what we do using git commit -m “required message” [Remember: until you commit your changes all the files will be stored in the staging area, only after committing it is stored in the local repository]

committing files

Woohooo! you’ve successfully inserted your files into the repository. But if you still have self-doubt then Git is there to help you out and check the status of your work. And you’re just a git status type away to remove your self-doubt.

checking status

Finally, we’re done! we’ve added our work files to the local repository! But we are supposed to do a lot more things with it right? So for all of that and more do refer to Part 2. Till then, Happy Coding! Keep Learning!..

--

--

Anwesha Sanyal

Hey, a astrophile and currently a bibliophile girl this side! I'm recently working on web development and competitive coding. I love to sketch my words.