WHAT IS A GIT?
Git is world's one of the most popular distributed version control system, which helps us to manage our project files. It will track changes made in project file which is present in git history.
GIT VERSION CONTROLLING
In our projects, we will use many type of files like html, css, js, images etc.While going through our development phases, we may need to revert changes on the code that we already done few months earlier due to some problems.Here git will help us to revert these changes by tracking our project files' evolution and provides us information about which code lines of our projects are changed on which time.
Most of our projects are completed as a team work. The changes made in project by one teammate may or may not be reflected on others copy. And finding changes made in multiple copies of files by team mates and merging it or waiting for teammate to complete the task and start to do work after that, is a tedious task and includes a lot of overheads. So we could escape from these tedious and miserable task by using git. The process of tracking, comparing and merging of project files are the tasks what git do. So simply saying, git could made collaboration of our works easy, every teammates get updated copy of project files and it makes our works more productive.
So, lets consider an example to analyse how git make our works more productive. Consider, I have to change the footer and header of our website. Without using git, first day started to change the header and footer of website.On the 2nd day, almost completed on updating footer feature but not the header. These two tasks are done separately and cannot merged due to incomplete updation of header and my hosting of website get delayed due to my incomplete task. And it will decrease my productivity. Now consider, doing the same tasks with using git. So now I could do updating both header and footer task ,switching between them when one feature updated , it will be combined with the major task, and then could focus on updating another feature.
INSTALLATION and COMMANDS USED IN GIT
Lets go through installation phase on git on your computer.
First in your web browser type : https://git-scm.com
Then Download installation file corresponding to your OS. Just click next,next, next through all installer , and complete the installation. After installing git, we could see, Git Bash and Git GUI. Git Bash is the command line used to type git commands.
Here we are going to discuss about some most popular commands used in git command line Git Bash. Before discussing about commands, we should be familiar with some terms in git.
Repository : It is the place where git stores all data, history and every changes made in a file of a particular project.
Working Directory: It is the folder location were project is located.
Staging: It means preparing something to commit or gain control over something that we are going to commit.
Commit: Git will reflect the changes that we made on file until we actively commit those files.
After installing git on your computer , you should personalise it. Let's find out some commands for that.
For that open Git Bash,
To find out the current git version type :
~git -- version
The main goal of git is to track project changes. It will track what file, and when it changes and also who makes that changes.
So, lets do git user configuration:
First set git user name,
~git config --global user.name"Your name"
Now, we will set email id,
~git config --global user.email "email@example.com"
To store all repositories related to our projects, first we have to create a folder and then is to navigate to that folder in command line.
To find , where command line exactly pointing type:
It will shows a location where command line pointing, something like this
Brad is the particular user's name.
To point command line to newly created folder type,
Sites is the folder that is newly created.
To create new directory,
~Sites mkdir "hello-world"
hello-world is my new directory. Now to point my command line to my newly created directory hello-world
Sites cd mkdir "hello-world"
To tell git to track my new repository hello-world,
~hello-world git init
Now I am going to create an empty .html file in command line, for that I am using touch command
~ touch "index.html"
touch "name of files to be created "
To find , what are the changes recently happen in files of repository, I could use,
Suppose, I created a file named index.html and want to commit to repository, so, first i should drag it to staging area
~git add index.html
Now, file is in staging area, and I wish to commit the file,
~git commit -m' My First Commit'
Here 'm' is used to display message. Here I wished to display the message " My First Commit"
In some cases, our files may get corrupted, deleted, system failure occurs, but if we are stored it in git repository, we could easily recover back using,
~git checkout --
This will restore the file back the way we committed it.
DIFFERENCE BETWEEN GIT AND GITHUB
Git is a software tool installed locally on your computer to track and manage project files. It is a command line tool and is fully focused on version controlling and code sharing and manage source code history. It was first released in 2005,maintained by linux and has no user management feature.It is used to coordinate work of programmers working as a team and its goals are providing speed, data integrity and support for distributed , non linear work flows.
Github is a cloud based service which is hosted on a web. It provides graphical user interface and focused on centralized source code hosting. It is a hosting service for Git repositories. It was launched in 2008, maintained by microsoft and has no built in user management feature. It offers all distributed revision control and source code management (SCM) functionality of Git as well as adding its own features.