Search code examples
jquerynode.jsgitgithubgulp

Source control and branches for a project using gulp


I am new to node.js/gulp and therefore apologies about the simple question.

I am creating a new jQuery project. And I am using node.js and gulp in my environment. Here is the directory/file structure.

/root-pluign-directory
    |
    ---- dist (directory that contains the files for release)
    |
    ---- src (directory containing the source code)
    |
    ---- node_modules (node.js modules used in my project)
    |
    ---- gulpefile.js (gulp file/instructions to manage my code from "src" to "dist", including minify, uglify, ... etc.)
    |
    ---- package.json (the package file for my project)

Now, when I use source control, what is the recommended way to check in and manage my code? Should I do the following?

  • Create a branch called gulp that contains node_modules, gulpfile.js, and package.json,

  • And create another branch, dist, for the dist directory,

  • And create more branches, such as master and any-additional-development-branch for the src directory

Is this the way to do it? What is recommended? What is the right approach.

Previously, I created a vendors branch, for all third party libraries in my project, but gulp is for development purposes, not for distribution purposes, so vendors would not work in this case.

Thanks.

Update

I previously created projects in PHP, mostly custom WordPress development, and now I am using node.js and gulp for the first time. My confusion is the following: the node_modules directory, the gulpefile.js and the package.json files, and the dist directory. I am not sure what to with them, Should add node_modules to .gitignore? What about the gulpefile.js and package.json files, and the dist directory?.

Thanks again.


Solution

  • The source control manager is here to track your changes, therefor your files.

    While gulpfile.js and package.json are two files you'll certainly change thus need to be tracked, i'd recommend you not to track the node_modules as you won't change anything yourself here ( npm will ).

    Second, git branches are here to track and isolate the different feature you might be working on at the same time.

    I'd suggest you read the excellent guide on git-scm about branches and when you'll need to get a better branching model, might I suggest this link giving really good advice on how to use branches efficiently.