Git and Github Tutorial: Beginner to Advanced (Part 1)
Tags: github, git, beginners, tutorial
Published: 2022-06-01 15:06:46

## Table of Content

*<br>*

>
📌 [Introduction](#Introduction)
>
📌 [Git Terminologies](#Git Terminologies)
>
📌 [Setup of Git and Github on System](#Setup of Git and Github on System)
>
📌 [Concept of Github and Git](#Concept of Github and Git)
>
📌 [Staging](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-2-2h5c#Staging)
>
📌 [Beginner commands of Git](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-2-2h5c#Beginner%20commands%20of%20Git)
>
📌 [Merging Conflicts](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Merging%20Conflicts)
>
📌 [Resolving Conflicts](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Resolving%20Conflicts)
>
📌 [Some Practices to avoid Conflicts](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Some%20Practices%20to%20avoid%20Conflicts)
>
📌 [Pull Request](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Pull%20Request)
>
📌 [Advanced Git Commands](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Advanced%20Git%20Commands)
>
📌 [Thank you](https://dev.to/suchintan/git-and-github-tutorial-beginner-to-advanced-part-3-1i09#Thank%20you)

*<br>*

## Introduction <a name="Introduction" />

*<br>*

Hey awesome developer 👨‍💻,

If you are searching or a cheat sheet to go through for *git or want to learn about git and github*.

Then you are in the right place 😇 !

This is going to be my **first series and please comment below about any enhancements that I can make or your feedbacks**. Believe me it really helps ✍!

I will be using **graphics to explain each topic in the simplest way possible** so you can *search by the keyword if you want to skip any portions ( in case of using it as cheat sheet )* 🤓

![Let's start](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g6qipb8dhi2gfc6y8l11.png)

**❗Note:-** I will be using a windows machine 🖥 to do all the stuffs so there can be a case that the commands may differ if you are using some different machine. Please browse it if the command doesn't work for your system though I will try my best to provide you with the command in such scenarios. Thank you.


First let's understand what is git and some terminologies that we need to get started with it.

*<br>*

## Git Terminologies <a name="Git Terminologies" />

*<br>*

1. **Commits**: These are the small changes of code that are pushed to the branches.

2. **Branches**: These are the different branches of code that are running concurrently and would be merged to the main branch when completed.

3. **Repositories**: It is the project which saves all the branches and the commits.

*<br>*

![Commits and Branches](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m34kz8y8fz63foslzin6.png)

*<br>*

Let's understand it easily with a diagram-

Here the tree 🌳 is the repository, the branches are the branches of the tree and the leaves 🌿 are the commits . Got it ?

Let's now move to the next part which is setting up git and github on your system.

*<br>*

## Setup of *Git* and *Github* on System 👨‍💻 <a name="Setup of Git and Github on System" />

*<br>*

>
- Create an account on Github

*<br>*

![Create an account](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ilg2qi8ka2oy1knb6f9.png)

*<br>*

> 
- Go on 👉 [https://github.com/](https://github.com/)
- Click on Sign up and create an account ✅.
- Now create a new repository by clicking on New button near Repositories.

*<br>*

![Github repository](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/duorg72igyv9iijv8xj9.png)

*<br>*

> 
- Type a name for the Repository and click on **Create Repository** to create one.
- Click on the copy to clipboard icon to copy the link #️⃣.

*<br>*


![Copy to clipboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kvhl3tvu9vsd29aj32s7.png)

*<br>*

### System Specific Commands ✍

*<br>*

>
### For Windows
>
- Download Git from 👉 [https://git-scm.com/download/win](https://git-scm.com/download/win) and install it.
>
>
### For Mac
- Use this command to download git 👉 `brew install git`
>
>
### For Linux (Ubuntu)
- Use this command to download git 👉 `sudo apt-get install git`

*<br>*

>
- Don't forget to put git folder location on environment variables for windows. To add it go to Environment Variables > (System Variables) Path > Paste `C:\Program Files\Git\cmd` if you haven't installed it on any other location.
- Now use these commands to clone the repository on your system 👇
```
mkdir <project_name>
git clone <repository_url>
```
The `repository_url` is the url that you copied to your clipboard from Github.

*<br>*

Great, you are done with the setup you needed for git 🙂. Now let's understand the concept of Git and Github on a grass root level 🌱. 

*<br>*

### Concept of Github and Git 📖<a name="Concept of Github and Git" />

Before digging into git and github we need to understand , **CVCS and DVCS to get the hang of the systems of version control**.

There are two types of version control-
1. **Central Version Control System ( CVCS )** - In this system there is a server where all the commits are saved on internet and every single commit are sent to the server through internet.
![CVCS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8knz1lryzf64f0tr55k.png)
2. **Distributed Version Control System ( DVCS )** - In this system there is a main server which is on internet but in addition to this there is one more server which is the user's system so every commits are saved on the users system and history of all commit's are on user's own server and while pushing it get's sent to the main server through the internet.

![DVCS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7h69lu1upigr0k14b20z.png)

Now I know many of you are wondering why we are studying these version control system. How is this connected to Git and Github. Right?

So, the answer is Git follows DVCS so Github, GitLab and all other services based on Git also does the same.

I know ! I know ! There are many questions that are popping in your mind so let's talk about Git now. How it really works❓

**Git is a service that is based on DVCS, it maintains a remote server on your system. That means your system is also a server while you are using git**. As you make a commit , the changes are push to your remote server. You knew that ?

But **if you push the commit's then those commit's are sent to Github through internet. Yes here Github is the main server which has all the commits saved and as you push the commit's someone else can pull the changes from main server to their system**. Got it?

![Git Diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2ldeyeporqdncy4usbld.png)

### Links 📌

Coming soon... 

All the links to future blogs of the series will be listed here.

We will be covering all beginner and advanced commands, along with various visual graphics ✌.

If you want to get the notification 🛎 of the upcoming blogs, don't forget to follow 👥 and subscribe.

Thank you 🙏

And at last I want to say 👇

Keep coding #️⃣ , keep rocking 🚀