I cannot find a sensible solution for as I reckon a very simple task. Consider I have some source
directory in my project, where all source files are. In development mode, I change source files, and Gulp minifies them into .min.js
and .min.css
and puts them into public
directory (to clarify, I'm building a node.js app).
Now, I have two branches: master
for production and development
for development.
.gitignore file on master
branch
.DS_Store
node_modules
source
...
.gitignore file on development
branch
.DS_Store
node_modules
public/javascript
public/stylesheets
...
The behavior I want to get: 1) ignore minified files for development (they are assembled and minified every time I change the code anyway), but keep source; 2) ignore source files for production (since I don't want to have them when I $ git pull
it into the production environment), but keep minified.
For some reason when I switch back and forth from master
to development
, git completely removes some files and breaks everything. For instance, it wipes all contents of every module in node_modules
, forcing me to do $ rm -rf node_modules && npm install
every time I switch branches.
Any help is very much appreciated.
The problem is also described here: Using git, how do I ignore a file in one branch but have it committed in another branch?, but with no working solutions.