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.
master
branch.DS_Store
node_modules
source
...
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.
Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are: dependency caches, such as the contents of /node_modules or /packages. compiled code, such as .o , .
If you want to permanently ignore these files, a simple way to add them to . gitignore is: Change to the root of the git tree. git ls-files --others --exclude-standard >> .
It feels to me like you're asking the wrong question. The minified scripts are "build products", not "source code". Seems to me like some sort of "make install" process should create them, rather than having them in source control. But I don't work in the web space so I do not know what standard practice is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With