Git has been a synonym for modern version control for a couple of years now. The challenge today is to find ways to use it professionally and productively.
Tower (opens in new tab), a desktop application for Mac, makes Git a bit more straightforward by helping people work more easily and efficiently with the Git version control system.
Crafting meaningful commits
Merely saving a new revision of your project won't necessarily help move things forward – especially if, when people come to look at your revision, it's difficult to see what has changed. Version control makes sense only when your commits make sense. This requires a commit to be granular: to only contain changes from a single topic.
Making granular commits ensures two things:
- Changes can be understood more easily. If you mix different topics in the same commit, your co-workers (and you) will have a hard time figuring out what each piece of code really does.
- Changes can be undone. Big, bloated commits with many different topics are hard to revert, because you will not only undo error-infected code, but also any other topics that have been crammed into that same commit.
With its 'staging area' concept, Git makes it easy to only include certain files in your next commit. Taking this one level deeper – working only with individual parts or even lines of changes – means your commits fit really perfectly.
This is tedious to do on the command line, which is where Tower comes in. It makes the process much more straightforward by simply selecting the parts and lines of code you want to include in the next commit.
Dealing with problems
I don't know about you, but I find myself making mistakes. Regularly. All the time, actually. No matter how much experience I have, mistakes remain a constant. I can't avoid them, but I can make sure that I'm able to quickly undo things.
Making it easy to recover from mistakes is one of the core jobs of a version control system. The good news is, Git allows you to undo almost anything. The bad news is, the necessary commands are spread all over the system, sometimes requiring quite complex sets of parameters.
Of course, this is where a GUI application shines: rolling back to an older version of your project – just like reverting a historic commit – is as easy as right-clicking the commit in question.
Your last commit can be amended by holding the alt key in the commit interface. It's even possible to discard unwanted local changes on just a single line of code.
Solving merge conflicts
Merge conflicts are nothing to be afraid of. They occur when a file is modified in contradictory ways. In this situation, a user must decide which version is correct (Git can't do this automatically), or even edit the final version until it’s correct.
As easy as this sounds, the situation can be quite abstract. That's why the latest version of Tower, Tower 2, has introduced a new conflict wizard that helps to visualise the situation. Users can clearly see which versions of the file have clashed, how they looked, who made the changes and in which commits.
They can then decide easily how the solution should look, simply by clicking the files they want in the final resolution.
Next page: more on how to streamline your Git workflow with Tower