git init

Work on Multiple Sub Projects at the Same Time (Git Branches)

Instead of always working and committing against the master branch you can create local branches as a way to work on multiple software features within the same git project.  This allows you to work on the same files, maintain separate versions of them, and keep track of it all.  For example, when you’re working on the same file(s) but might not want to put that new feature in yet, but still need to support existing code with a hotfix.


Create new branch named “feature12” and switch to it.  This will be a local branch only.

git checkout -b feature12


Do your work and commit your changes

git commit image_resizer.js -m 'support for feature 12'


Switch back to master.

git checkout master


At this point you could start another branch if you needed to work on feature 13.  You’d just go back to the 1st step.  But let’s say you didn’t want to do that, but instead you want to merge your new feature 12 code in with master.


Merge your new stuff in the master branch.

git merge feature12


Now that you’ve merged it into the master branch you no longer need the feature12 branch.


Remove branch

git branch -d feature12



git push

Leave a Reply

Your email address will not be published. Required fields are marked *