DEV Community

Cover image for Git and Github Tutorial: Beginner to Advanced (Part 1)
SUCHINTAN DAS
SUCHINTAN DAS

Posted on • Updated on

Git and Github Tutorial: Beginner to Advanced (Part 1)

Table of Content


πŸ“Œ Introduction

πŸ“Œ Git Terminologies

πŸ“Œ Setup of Git and Github on System

πŸ“Œ Concept of Github and Git

πŸ“Œ Staging

πŸ“Œ Beginner commands of Git

πŸ“Œ Merging Conflicts

πŸ“Œ Resolving Conflicts

πŸ“Œ Some Practices to avoid Conflicts

πŸ“Œ Pull Request

πŸ“Œ Advanced Git Commands

πŸ“Œ Thank you


Introduction


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

❗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.


Git Terminologies


  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.


Commits and Branches


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.


Setup of Git and Github on System πŸ‘¨β€πŸ’»


  • Create an account on Github


Create an account


  • Go on πŸ‘‰ https://github.com/
  • Click on Sign up and create an account βœ….
  • Now create a new repository by clicking on New button near Repositories.


Github repository


  • 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 #️⃣.


Copy to clipboard


System Specific Commands ✍


For Windows

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


  • 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>
Enter fullscreen mode Exit fullscreen mode

The repository_url is the url that you copied to your clipboard from Github.


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 🌱.


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
  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

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

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 πŸš€

Top comments (5)

Collapse
 
sumyya_khan profile image
sumyya khan

Thanks, Really helpful content

Collapse
 
suchintan profile image
SUCHINTAN DAS

Welcome sumyya khan. If you want notification πŸ›Ž for such amazing content , you can click on the follow button.

Thanks in advance πŸ™‚

Collapse
 
sumyya_khan profile image
sumyya khan

sure

Collapse
 
yongchanghe profile image
Yongchang He

Thank you for sharing!

Collapse
 
suchintan profile image
SUCHINTAN DAS

Welcome, Yongchang He πŸ™‚. It's a series so if you want to get a notification for further parts of the blog. You can click on subscribe ✌.