This is part 1 of an introduction to Git, a version control system that’s very popular with software development. Part 2 will be posted later this week.
A History of Version Control
Version Control Systems (VCS for short) have been around for awhile in software development. They are programs that help you make and record changes to files over time with the ability to bring back specific versions later on. It’s like the Save feature in Microsoft Word but you can have access to all your previous drafts, not just the most recent saved version.
The first type of version control systems were local only on your computer, without any network connecting. Soon, with the rise of the internet and networks connecting to servers, centralized version control systems that housed projects on a shared server attached to many computers became the popular method. A centralized VCS was better, since multiple people to connect to the server at once to work on a project. The downside with both the local and central VCS systems though was that they both relied on the project being stored in one location. If something happened (stolen computer, server destroyed or compromised, etc.), the project was gone.
Thus came the Distributed Version Control System (DVCS). A DVCS is the current setup for a version control system, and Git is an example. With a DVCS, the project is cloned on both the server and all the computers working on the project. If connected to a network and the server, you can push updates to the project in the network. However, if you are not connected to a network, you can still push updates locally to the project on your local disk. This means that a compromised server or the destruction of a computer or two will not mean the total loss of your project.
A History of Git
Git was created in 2005 to solve a problem on Linux distributions. Before 2005, Linux had an agreement in place with a proprietary version control system called Bitkeeper (the agreement was created in 2002). In three short years, the relationship between the two sides disappeared and the free use of Bitkeeper was revoked. To fill the void, Linus Torvalds (the creator of Linux) spearheaded the creation of Git, a free open-source DVCS for developers.
Git’s focuses on five core areas: speed, simple design, support for non-linear development (it can branch out into various ‘alternative realities’), fully distributed, and the ability to handle large projects easily.
How Git Thinks
Git thinks of file changes as snapshots of the project as a whole. With a commit, Git takes a snapshot of your entire project and saves it as a new version, even if you only edited a small part of that project. If other parts of the project are not changed, that part of the snapshot is linked back to the previous identical file. You can also bring up previous snapshots of your project to compare or split off and create new branches of your project.
Additionally, you have the whole history of the project on your computer when you download the project onto your computer. Since you are working on a local host, the speed is much faster than if you connected and pushed updates to a server only. Also, working on a local host means an internet is not constantly required to make updates to the project on your computer.
There are three states a file in your project can be in when using Git:
- Modified: changes have been made but are not committed yet
- Staged: your file is marked for commit in your next snapshot
- Committed: data is stored in your local project database and a new snapshot is created
Top comments (3)
Thanks Aaron! Looking forward to part 2.
Hey Jason, I put up part 2 here. I hope you enjoy! dev.to/aaronmccollum/introduction-...