Why To use Distributed Version Control system (DVCS)
In my last blog I have explained about different Version control systems.
Here I am giving an overview why we should use Distributed Version Control system (DVCS):
- It gives us liberty to work fully offline.
- It encourages frequent commits and experiments
- It is easy to switch work like easily switch to different branches on priority even if we are in middle of something.
- It is a powerful tools for viewing and rewriting history
- Increasingly popular as more productive
Even DVCS have most of good things, there are few points for Why not used Distributed System:
- It is harder to use day to day
- Few non OSS project need the ability to rewrite history
- Git does not handle binaries well,
- Security is defined at repository level
Let’s start with Git……
- GIT was born on 2005. Linus Torvalds was the creator of GIT. He created GIT to meet the needs of Linux projects
- GIT is Distributed version control system. It can track changes to a file and allows you to revert back to any particular change.
- There is a central cloud repository as well where developers can commit changes and share it with other teammates.
- Every developer’s working copy of the code is also a repository that can contain the full history of all changes.
Git can be used for:
- It help us to create repository.
- It help us to store different version of application/product during life time including creation and multiple modification
- It helps to manage changes in product, restoration of previous version
- It enables comparison and inspection of the different versions of same application/product.
- It promotes collaboration between developers, as they share common code base.
- It allows maintaining accountability, as we can track all users’ changes they made in the code.
Now I will explain about Git (Git bash) and Git hub and, Is they both are same? Or there is any difference in between these two….
When I have started with Git , I too was very confused about both, I was not sure why we have two Git…..
Here I will explain both Git and Git hub. And why they both are two different….
We are going to use term Repository many times in course. Repository this is a data space, where all project file data related files are stored.
In Distributed Version Control System we got central repository as well as local repository, Developers 1st make changes into their local repository and then they push or transfer changes into center repository an also update their local repository with center repository with pull command time to time.
Git is a free and open source distributed version control tool, that allow to perform all operations that we are suppose to do for any version control tool like commits, manage commits, fetch data from center, push local file to central server etc.. It is designed to handle everything from small to large files/projects with good speed and efficiency. Git is a command line tool.
Git hub is a code hosting platform for version control collaboration, Git Hub is web based graphical interface. or we can say Git Hub is a web page where we can published projects and collaborate with other people. Git hub is like a social network, different user can share their code on one platform.
Features of Git:
- Distributed: It is a distributed tool and all code is distributed on all developer’s local machine with all history of project.
- Compatible: It is compatible with existing version control systems too.
- Non-linear: Working with git records current state of project as tree graph of index. we can navigate and visualize our project easily.
- Branching: It is very easy to create, delete and merge branches with in Git. Multiple local branches for different work created in very short time. Master branch always have production code.
- Lightweight: Data is stored in compressed form and it will convert when we fetch it on our local repo to start work.
- Speed: we don’t need to travel every time to fetch files, we have all files in local repository. It is written in C language and C language is close to machine language and reduce all run time overhead , it makes all process faster. Git is 10 times faster than other version control tools
- Free and Open Source: you can modify its source code according to your needs.
- Reliable: we have backup of all files.
- Secure: when make change it will create all history, like who made changes and there commits with comments.
- Economical: In case of DVCS, developers don’t interact with the server unless they need to exchange any changes. All the that work happens on the client side, so the server hardware can be very simple, hence a lot of money can be saved on costly servers
- Repository: A Repository is a directory or storage space for our projects where data is stored or manage into a organized manner. It can be local to a folder on our computer, or it can be a storage space on Git Hub or another online host. we can keeps code files, text files, images file, everything related to project on repository.
There are two types of repository:
1. Central repository
2. Local repository
Central repository: It is located on remote server from where every developer can share and exchange data.It consists of ‘.git’ repository folder
Local repository: It is located on local machine of developer and belongs to the person who has that machine. It resided as a .git folder inside our project’s root.
Few points that we should be clear for Git Repository:
- You have access to all files in your local repository, whether you are working on one file or multiple files.
- You can view public repositories without an account if you have the URL for that repository.
- Each repository belongs to a user account or a team. In the case of a user account, that user owns the repository and in the case of a team, that team owns it.
- The repository owner is the only person who can delete the repository. If the repository belongs to a team, an admin can delete the repository.
- A code project can consist of multiple repositories across multiple accounts but can also be a single repository from a single account.
- Each repository has a 2 GB size limit, but we recommend keeping your repository no larger than 1 GB.
At this point we know Git and GitHub.
Now we will install Git and will start to learn commands and perform operations.
Installation of Git ,
we can get the list of downloadable packages from http://git-scm.com/downloads
Download Git for windows and Git is downloaded in C drive under Program files with name Git bash
Now we will open the editor by clicking Git Bash (short cut created on desktop), it will open a command line editor and now we are ready to start with Git.
To create a Github handle visit https://github.com/ and create your github user . GitHub user name is called handle og GitHub.
Here let me introduced you with one more thing that is bitbucket.
- In order to create a bitbucket handle visit https://bitbucket.org/ and follow instruction to create your bitbucket user
Here is a basic overview of how Git works:
- Create a “repository” (project) with a git hosting tool (like Bitbucket or Github)
- Copy (or clone) the repository to your local machine
- Add a file to your local repo and “commit” (save) the changes
- “Push” your changes to your master branch
- Make a change to your file with a git hosting tool and commit
- “Pull” the changes to your local machine
- Create a “branch” (version), make a change, commit the change
- Open a “pull request” (propose changes to the master branch)
- “Merge” your branch to the master branch
Same as GitHub we have one more hosting tool and it is Bitbucket. We can use git with BitBucket as well.
Bitbucket is also a web based hosting tool .It is owned by Atlassian.