Chunks of Git and Github

Before diving in git and github ,first we have to have clear concept about what is version control system.

Version Control System??

We can thing version control as management system that manage the changes that you make in your project till the end the changes might be some kind of adding some new files or you are modifying the older files by changing the source code or something . What the version control system does is that every time you make a change in your project . It creates a snapshot of your entire project and save these .These snapshots are actually known as different version .

Why version control?

You might be thinking that why should i need a version control . I know the changes i have made and maybe this changes just because i am correcting my project or something . But there are number of things because of why we need version control . Suppose you are 4 members group working on a shared project .Every is trying to modify same thing at the same time. Without collaboration of version control system ,there might appear a lot of conflicts when all members are going to merge . You might not know who have done what kind of changes and this will end up in chaos .

Git and github ??

Github is the central repository and git is the tool which is going to create my local repositories. Let me tell you what is exactly github . People actually get confused between git and github . Because of i think it is kind of the same thing maybe because of the they sound very alike but these two are very different thing , git is a version control tool that allow you to perform all these kind of operation to fetch data from the central server and push all your local file into the central server . This is what git allows you to do. It is just a version control management tool. Whereas the github is a code hosting platform for version control collaboration .It is like a company that allows you to host your central repository in a remote server .

Well,here ,We gotta know about two terms Central Repository and Local Repository .

Central and Local Repository:

A depository or storage space where projects can live. It can be local to a folder on our computer or it can be a storage space on Github or another online host.

There are two types of repositories :

  1. Central Repository
  2. Local Repository

The central repository is typically located on on the remote server which is Github. Whereas local repository is located on users’ local machines in dot git folder .This folder will be inside project root and it contains all the templates , all the objects and every other configuration files when we create local repository . Since we push all the code to the central repository , central repository also contains dot git folder contained all other files as well. The sole purpose of having the central depository is we all the collaborators and developers share and exchange data because someone might be working on a different problem and someone might be needing that. So what we can do is developers push all problems that are solved to the central repository so that everyone can pull those code for using themselves . On the other hand , local repository is meant for developer own to access and work .

Git operations & Commands :

There are various git operations and command to do all the things . This is how we are going to optimize git and github features. I will show you one by one . So lets start .

The first thing we need to do is creating a local repository . In order to create a local repository , we need to use ‘git init’ command in git bash . It will create a dot git folder in the working directory .

Now we have to link our local repository to the central repository . In order to do that we have to use ‘ git remote add origin ’ command. Here link should be the remote repository link .

Now we are going to get the remote repository on our local machine. In order to pull the remote repository to local repository ,that we have to use ‘git pull origin master’ command .

Now, lets assume that we have created a text file in our local repository which is yet not pushed to the remote repository . To see the unchecked file , we have to use ‘git status’ command .

To commit the newly created file called ‘myTextFile’ to the remote repository , we have to index this file first .In order to do that we have to use ‘git add ’ command.

Now we are going to push the newly created file . To do that , we have generate SSH key . To generate SSH key , we have to use ‘ssh- keygen’ command . After getting the key , we have to put that key in the github account .Then we have to use ‘ssh -T git@github’ command to connect the remote repository .Now we have to use ‘git push origin master’ command to push all the files to the remote repository .


Written By

Rakib Uddin


Facebook Feed

Copyright © 2021 Shield Technologies (Private) Limited