Why You Should Use Git
Ever since version control systems such as Git have become widely-known and well-used, modern development processes have radically changed.
Here are some reasons why Git has the power to improve your development workflow.
Git Encourages Modularization
In even the smallest development projects, developers are often required to work on multiple components in parallel. Feature X, bug #102, a new UI for a sign-up form, etc.
Among many others, here are a couple of major issues with projects that aren’t version-controlled:
Project dependencies will be painful to manage. Team members must sort out which changes affect which components.
Unfinished and experimental code will mix-in with production-ready code.Without version control, there is a huge chance that an unstable piece of code gets deployed to a production environment.
Imagine these scenarios.
Your client tells you that they don’t want feature X anymore.
Or what if you find that feature Y — an experimental feature you have been working on — can’t be implemented?
How do you get code removed safely from your code base?
Using branches is the solution to these commonplace development problems. Although Git wasn’t the version control system (VCS) that introduced the concept of branching, it’s the first of its kind that makes it user-friendly.
Git Encourages Creativity and Experimentation
Git branching will improve your code-quality and productivity. It facilitates creativity and experimentation by removing your fear that the current version of the project will be affected while you are trying out ideas, giving you an environment where you can confidently explore and develop your project’s future features.
With Git, you can even create multiple branches that approach a given problem in different ways, test each of them with your master branch (the most current version of your project), and then choose the best option.
Git Allows You to Undo Your Mistakes
In Git, you can undo almost everything.
Being able to undo things gives your team the courage to try out ideas and concepts without the risk of breaking stuff, which in turn fosters a culture of innovation.
Git Makes Your Progress Clear
A commit in Git refers to the act of recording changes you have made in your source code.
When used properly, Git makes it easy to craft very granular commits. You can see what changes have occurred down to the microscopic level: Git will tell you what characters and lines in your source code have been altered. If you want to compare two versions of a file or the difference between two of your commits, you can issue Git’s diff command, which will highlight the differences between them.
A side note when using commits: As a good version control policy, I recommend that each commit should only contain changes that belong to a single topic.
For instance, if you’re fixing a specific bug — let’s call it bug #200 — that requires multiple source code changes across several files, all those changes should be under one commit in order for you to easily track changes to your project related to that bug. This way, you can document that "commit X fixed bug #200". A side benefit of this commit policy is, when you encounter another bug similar to bug #200somewhere else in your project months from now, you can review how you resolved the first bug.
Mixing different topics in one commit makes it hard to see what things were added or resolved.
Also, multi-topic commits makes it more difficult to roll back to a previous version if you ever find the need to do so. Imagine a commit that contains changes for bothfeature A and feature B. If you find out later on that you introduced a severe security leak with feature B, you’ll have to roll back the code for both topics just to get rid of the problem.
You Can Work Offline
A lot of companies underestimate the benefits that can be had if their developers were to be able to work offline.
Being able to code on your laptop without having to connect to your company’s servers is not only about being able to work during a commute or while at home (which a lot of companies don’t permit due to security restrictions).
More importantly, being able to work offline makes you more fail-safe as a team: While with a VCS like Subversion or CVS, a developer can’t continue their work when a central server goes down, this is not an issue with Git.
In Git, developers can perform everything on their personal computer, making them independent of possible infrastructure downtimes.
Never Lose Data Ever Again
Losing data and not being able to recover it can break a dev project.
We’ve all heard or experienced our own set of horror stories about failed backups and servers. It’s good to know that when using Git, every developer working on a project has a full-fledged copy on their machine, including the project’s complete change history.
And if your team uses a remote source code repository such as GitHub, then the chances of losing your work in the event that your on-site backups fail is much smaller.
If your backups break down, losing data isn’t even a possibility when using Git: Just take any team member’s local repository and restore in minutes.
How to Use Git Today
Git has stepped out of being a technology for early-adopters. Today, more and more developers are using it to improve the quality of their code and workflow.
If you would like to get started with Git right now, read these resources:
How to Quickly Get Started with Git
Top 10 Git Tutorials for Beginners
Interactive Git Tutorials
6 Myths Preventing Developers from Using Git
Speed Up Your Web Development Workflow with Grunt
The Ultimate Guide to Version Control for Designers