Book Image

Data Oriented Development with Angularjs

Book Image

Data Oriented Development with Angularjs

Overview of this book

Table of Contents (17 chapters)
Data-oriented Development with AngularJS
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Using Git flow


Now imagine a very plausible real-life situation where you start working on a new nontrivial feature. Since this feature is nontrivial, imagine you'll take a week to complete it. You start working on the main branch of the project. After a couple of days of work, you still haven't checked in your code yet, because the feature you're working on is not yet complete, and all of a sudden your boss comes and tells you that there is a critical bug which needs to be fixed immediately. Now what do you do? If you are working with a VCS tool like Subversion, you'll probably make a patch, save it somewhere, undo the changes in your main code, and then start working on the bug fix.

Keeping your code checked out for long periods of time is not a very good way of working; the recommended way is to check in at short intervals, and if that is unavoidable, then at least check in the changes by the end of the day. So the trick is to work on small chunks of code which can be checked in by the end of the day. This way you can avoid lengthy code merge sessions.

But this is not true with Git. Git makes branching and merging so easy that there is a much better workflow for the previous scenario; every time you start working on a bug fix or a new feature, you do so in a different branch, and when you are done with the bug fix or the feature, you merge the branch with the develop branch. Now you can do all this branching and merging with Git, but there is a nice little utility called Git flow (available at https://github.com/nvie/gitflow), which is perfect for such scenarios and makes these tasks a breeze. Before using Git flow, I suggest you read a successful Git branching model (available at http://nvie.com/posts/a-successful-git-branching-model/) by Vincent Driessen. Git flow can be installed by following the instructions available at https://github.com/nvie/gitflow/wiki/Installation.

As per the Git flow method of working, we always have two main branches called master (which is used for production releases) and develop (where all development is done). There are other supporting branches such as feature, release, hotfix, and so on. So once you do git init on an empty repository, you have to initialize git flow in the same repository:

$ git flow init

This is demonstrated in the following screenshot:

Git Bash showing the git flow init process

Just keep accepting default values for the questions that git flow asks and you'll be good to go. So assuming that your development happens on the develop branch, whenever you have to start working on a new feature, you just have to perform the following action:

$ git flow feature start <featurename>

Here, <featurename> is the name you want to give to your new feature. As soon as you do that, the Git flow makes a new branch called feature/<featurename> and switches your repository to the new branch. Once you are done with the new feature and are ready to put this piece of code into action, you can merge your code into the develop branch with the following command:

$ git flow feature finish <featurename>

Now, git flow merges the feature branch's code into the develop branch, deletes this feature/<featurename> branch, and switches the repository back to the develop branch, all in one sweet little command.