Back when I first started to use Git for version control, I wasn’t sure if all the learning I invested into it would pay off. Branching, staging, stashing — these Git terms were all foreign to me.
Today, I can’t imagine life without Git. Git not only gave me a much-needed ability to version-control my work, it also made me a better programmer.
Here’s a series of simple tips that will help you make Git an important part of your web development workflow.
Tip 1: Spend Some Time Learning Git Basics
Learning the basics doesn’t mean you have to read the entire Git documentation from start to finish (although if that’s your thing, I wouldn’t discourage you from doing it).
There’s so much educational content on Git that I’m sure there’s something out there that fits your personal preferences and optimal learning style.
Here are a few Git learning resources to check out:
- How to Quickly Get Started with Git
- Try Git is a 15-minute interactive Git tutorial
- Tips and Tricks (Ry’s Git Tutorial) is a hands-on tutorial on common Git features
- Git The Simple Guide
- Git Ready is a website that has a collection of simple and short Git tips
- Git Cheat Sheet
- Git Tower’s Learn section is a list of Git learning resources at my website
- Official Git Tutorial
- Training: Git Basics (videos) is a YouTube video playlist
- Pro Git is an online book to read if you want a deep understanding of Git
Tip 2: Start with a Simple Git Workflow
Less is more.
Often, Git is associated with complex workflows. Let me say this though: You don’t have to completely master Git in order to instantly reap its benefits.
Git workflows can be extremely simple — and in a lot of cases "simple" is exactly all you need. Sure, you can use multiple remote repositories, issue pull requests, rebase your changes, etc. but you don’t have to if you don’t want to.
Starting with a simple workflow also makes it easier to add more complexity later on when you need Git’s more advanced features. The advanced features will be there for you when you need them.
Here are some examples of various Git workflows that you can take ideas and inspiration from:
- Git workflow for designers
- Git workflow of Markus Prinz
- Common Git workflow of Yehuda Katz
- Git workflow for Agile teams
The overarching point is this: Don’t stress out about needing to learn everything about Git. You can start using Git today.
Tip 3: Stop Being Afraid of Making Mistakes
A great thing about Git is that it’s almost 100% foolproof.
Keeping the following things in mind should let you sleep easy at night:
- Git hardly ever deletes data. Even actions that seem to delete items in reality actually add data to the system that will let you quickly undo deletions.
- You can undo almost everything in Git. I encourage you to experiment and explore Git and try out your ideas because this is one of the major benefits of using a version control system.
- Every member of your team has a repository cloned on his/her computer. Essentially, this is sort of like a redundant backup of the whole version-controlled project (including the full history) in the very unlikely event you do mess things up big time and can’t recover your mistake.
Tip 4: Understand the Concept of Branching
The concept of branching in Git is one of the most useful things you can learn at the start. Branching allows you to keep separate developments of one project possible and is a key component of being an effective Git user.
It may not sound like a big deal at first, but once you fully understand the concept of branching, you’ll wonder how you could have possibly lived without this ability.
Although other version control systems use the branching concept too, Git is the first system that really makes it easy and useful.
Here are some resources to read that will help you understand the Git branching concept:
- LearnGitBranching! is an interactive tutorial on Git branching
- Git Basic Branching and Merging
- Branch Wizardry is a short guide on Git branching and merging
- Git Branches is a simple tutorial with plenty of illustrations
- A successful Git branching model
Tip 5: Learn About the Staging Area
Version control is most useful when you wrap up only related changes in a commit. This guarantees the commit can be rolled back easily without side-effects. The habit of making frequent commits also helps your coworkers more easily understand the progression of your changes.
Git makes granular commits easier than any other version control system (VCS) because you can determine which changes exactly shall be in the next commit.
A Git feature called staging area makes this possible.
Learn to use and love the staging area because it’s one of the most essential and unique components of Git.
Here are some resources about Git’s staging area:
- Why the staging area is so useful
- What is the benefit of Git’s staging? – a discussion thread about the value of Git’s staging area
- Aha! Moments When Learning Git – a blog post that highlights the enlightening experience you’ll get after you realize how the staging area works
- The staging area is a short guide on Git’s staging area
Tip 6: Use a Git GUI
Although using a GUI is definitely not a requirement, I highly recommend it.
Using a GUI makes a lot of tasks easier and gives you a head start.
After all, using Git is not about learning commands and parameters by heart, it’s about using Git to improve your coding workflow. If a GUI enhances your coding workflow, there’s no reason to make things harder on yourself.
Here are some Git GUIs to check out:
- Tortoise Git – open source Git GUI for Windows
- GitX (L) – open source Mac OS X Git client
- SourceTree – free Git (and Mercurial) GUI for Mac and Windows
- git-cola – an open source Git GUI
- Tower – My company’s Git GUI for Mac users
Using a GUI will not relieve you from having to learn the basics, but once you’re happy with the level of Git mastery you have, investigate the tools that will make your life easier.
Tip 7: Commit Yourself to Using Git
Using a new tool can cause a bit of a headache in the first few days. The only way to get through this learning curve is to keep going.
Don’t look back; make a full commitment. Introducing Git into your normal coding workflow will soon prove to be one of the biggest and most significant things you’ve done in a while.
Avoid making exceptions like "I’ll use Git for these projects, but not for these other projects." At least at first.
The mindset of fully committing to Git gives you more opportunities to practice, makes things simpler because you know that the current project you’re working on is using a version control system, and most importantly makes Git a part of your coding habits.
In the future, you’ll see that there are just some situations where you don’t need to use Git. You won’t know what those situations are until you use Git in all the situations you can.
At the start of your journey towards Git mastery, make a 100% commitment to it.
- Top 10 Git Tutorials for Beginners
- Introductory Guide to Git Version Control System
- Offbeat Tips for Being More Productive and Efficient at Work
- Tips for Building Your First Web App
- 7 Crazy Tips That Will Help You Become a Better Coder