Introduction to Git

0
4 min read
Git

Git is an upcoming platform with vast application and high security in technical field.Git was developed by Linus Torvalds, the creator of Linux Operating System. It is an open source platform where one can store and update their project codes. In real world , applications are built by multiple developers and git becomes a common platform for them to share and update their code.

In technical terms Git is an Open Source Distributed Version Control System. in a Distributed Version Control system a local content is stored on each node (one’s computer). It is a centralized server where all the team members update their changes. This means that git is code tracker that can handle recursive changes based on the needs. It has two types of storage facilities. Git is an open source i.e world wide free platform which anyone can use. Distributed ,i.e,the content can be stored in server ,i.e, globally or the local repository ,i.e, in the coder’s computer. Version Control System means it can be stored while paralleling making necessary updates and changes to the code content.

Why Git?

  1. Free usage – As git is an open source anyone from anywhere can use it without any cost.
  2. Scalability – With Git, updates and changes are easily made along with sharing using commit and branch options.
  3. Easy collaborations- Multiple developers can access the code and merge all into one source.

Best Features of Git-

1.Simple to use -One can just follow set of commands to build a repository and share it in a vast community or team without any hindrance.

2. Git integrity – Git uses check-sum along with SHA-1 Hashing algorithm to preserve data loss during transactions or being tampered from third party.

3. Performance – Git has the best performance with features such as Committing, branching, merging all are optimized than other systems.The branching model of Git is quite unique as it allows one to have multiple local branches which are independent of each other.

Steps to add code to git-

In software field constant updates and optimization of codes is necessary thus using git makes this easy and efficient.For this a repository is needed to be built in git. Lets see the steps for making a git repository.


In a folder git-setup add a local git repository by following command

1]Creating a local repository

cd git-setup
git int //adds the git respository


1.Create a any type of file in the folder. Here we will take two text files ‘start.txt’,’end.txt’ and add a text ‘beginning code’ and ‘ending code.

2] Staging and Committing

2.Commiting the step where the code is actually added to the respository but before that we stage the code.

Staging-

git add start.txt end.txt

Note- to add all files in a respective folder usegit add.’

Commiting-

git commit -m "Initial Commit"

‘Initial Commit ‘ is message to indicate the changes done.


This is used to check the modifications done in the code.
Add a text ‘intermediate code’ in start.txt use git the following command to see the status of modification done.
git status
Now again add the code to staging area and commit as follows

3.Git Status and Git Log

git add start.txt git commit -m "start.txt is modified" //similary end.txt could be modified.

Some extra useful features in git-

1] Branches
A branch is a pointer that points to the latest commit done in git. By default when not branched the master branch is committed.
Creating a branch called ‘branched’.

git branch branched //branch created default in master branch
git checkout branched //pointing to branched

Using git for github purposes.

Add the following command for pointing to your local respository

git remote add origin 'url to respository'

Now push all the code from local to remote respository

git push -u origin master

To pull or take from remote to ones own respository

git pull origin master

Thank you for reading.Hope the basics of git is clear.

Choose your Reaction!
Leave a Comment