Today’s guest blog post comes from Marcel Pociot (@marcelpociot) from Germany. Marcel works as a Web Developer and in his spare time he is an active “Titan” member, develops apps as a freelancer and works on several open source Titanium modules available at Github.
So you’re a Titanium Pro and know how to develop your apps. Or maybe you’re just getting started with Titanium and working on your first app.
Whatever type of Titanium developer you are, at some point during your development workflow you wish you could roll back to a previous state of your code or be able to reproduce the steps needed for a specific feature. This is where Version Control Systems come in. In our case we’ll concentrate on the most commonly used Version Control System : Git.
What is Git – main use of Version Control Systems
Git is a Distributed Version Control System (DVCS). A Version Control System provides the ability to create a history for files and allows you to easily switch between different states / versions of files within your project. Once you tell Git which files you’d like to track, it will record every change you make to them. The collection of files and their history are saved in what is called a repository.
Unlike Centralized Version Control Systems (CVCS), Git has no central server to store the data. Every local copy holds a full history of the source code. This is not to be confused with GitHub, a server used to store projects tracked with Git. Although GitHub acts as a centralized server, every developer still has a complete copy of all the files in the repository, along with its full history.
If you’ve never heard of Git, or you’re unfamiliar with the Git terminology and methodology, I suggest you take a look at the excellent Github introduction at https://try.github.io/levels/1/challenges/1
Alright, so how can Git improve my development workflow?
Imagine the following scenario: You’ve recently finished version 1.0 of your App and published it in the App Store. You start developing a new feature and suddenly a critical bug occurs that needs to be fixed in the live version.
Without the use of Git / Version Control you need to revert your current work on the new feature, apply the hotfix and finally roll back your feature work. As you can imagine this process is not very fail-safe and depending on the time you already invested in developing new features it becomes more complex to revert to your original state.
When you use Git, you simply add the changes you’ve made so far to the version control and “commit” them. You are then able to roll back to your previous version of the source code, the version that was sent to the App Store. After applying your bugfix / hotfix you can continue your feature work where you left off.
What about Titanium Studio?
Titanium Studio has built in Git support, that allows you to easily switch to version control right now. By selecting Initialize Git repository Titanium Studio creates an empty Git repository.
“Empty” in this case means that you need to add your existing code to the version control (repository). This can be achieved by using the Commit… option within Titanium Studio.
You will then be presented with a list of all new or changed files that aren’t yet under version control.
Add all files by clicking the >> Button and enter a commit message.
This message is used to describe the work you’ve done and allows you to roll back more easily.
When changing files Titanium Studio will indicate the files that have changed and are not added to the repository yet.
The commit window will give you a more detailed list of the changes in each file line by line.
I hope this blog post gave you a short overview over the improvements a version control system can give you. Version control should be a must have for developers – whether they work alone or in teams.