Storage with MongoDB and Git

2015
15
March
3:44 pm

Working between my desktop at home and laptop whilst in the studios, working from a flash drive or constantly uploading work quickly stopped being viable as the project became more complex. In order to alleviate this, I decide to use the git version control and github to host my project during development. Git provides a quick method of syncing modifications between multiple machines or developers. Each modification to a file is registered by git, is reversible and can then be pushed to a repository on the github server. When working on from a different location, the complete revision history (or list of modifications to each file) can be pulled from the server to the new machine and work can continue.

There is an active community around Node which provide modules to extend the functionality of Node available via the node package managers. One example of this is Express, which I’ve mentioned in my last post. These are open source projects also hosted on github and are regularly maintained and updated. There is some debate over whether or not node modules should be stored in your repository.

The main reason to commit third party modules to your repository is for a codebase which is if its expected for the application to exist over a timeframe which may outlast the node package manager or to ensure that the it will not break if the module version required is removed from production.

At this stage, i’m going to omit node modules from my repository and rely on npm to handle my dependencies. Between my two computers and deployment server, my application has to run on three different operating systems (OSX Yosemite, Ubuntu Server 14.04 and Windows 8) and a number of node modules are installed platform specific so at this point, storing my dependencies wouldn’t serve any purpose. Certain files or folders can be omitted from git by simply including an entry in git’s ‘.gitignore’ file.
Initially, I had hoped to store my testing MongoDB database within the source directory and use git to sync it between my workspaces to keep stored test data consistent. Although this was intended to save time, while the MongoDB server was active, the database files are locked and not able to be committed by git. To overcome this, the MongoDB must be shut down when committing to git and although this is a relatively quick process, it adds up and makes git -which is a productivity tool- much less productive. To avoid having to stop the server for each commit, the database folder will be added to .gitignore along with node_modules.

Posted in: Honours Project
Tagged with:

Leave a Reply

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