Generate branch specific .gitignore.
yarn add build-ignore -D
npm i build-ignore -D
In order to use build-ignore you will need to create a gitignores directory with a text file using the name of your branch specific gitignore as well as your regular(master) gitingore.
- ./gitignores|_ gitingore_master.txt|_ gitingore_specialBranch.txt
From your terminal run
./node_modules/.bin/build-ignore. It will check the current branch and look for it in the gitignores folder. If one is not found it will create one using the gitingore_master.txt file. Must add .gitignore to each gitignore text file in order to avoid having to mess with tracking of actual .gitignore.
Use as a post-checkout git hook to have build-ignore run automatically when changing branches by adding the following to the
#.git/hooks/post-checkout#!/bin/shBRANCH_SWITCH="$3"#check if it was a branch checkoutif [[ $BRANCH_SWITCH -eq 1 ]]then./node_modules/.bin/build-ignorefi
Alternatively, you can use a githooks module like husky and add the following to your package.json scripts section.