Skip to content

Instantly share code, notes, and snippets.

@atfzl
Created September 3, 2016 10:36
Show Gist options
  • Save atfzl/2eb06c96cedb2d8c22d707a31a12ac6e to your computer and use it in GitHub Desktop.
Save atfzl/2eb06c96cedb2d8c22d707a31a12ac6e to your computer and use it in GitHub Desktop.
use branch specific git ignore configs
#!/usr/bin/env node
var execSync = require('child_process').execSync;
var exec = function (command) {
return execSync(command, { pwd: '../../', encoding: 'utf8' });
};
// get current branch name as single value
var currentBranch = exec('git rev-parse --abbrev-ref HEAD').trim();
// branches with specific ignore files
var branchGitignores = exec('ls .gitignores').trim().split('\n');
// remove previous exclude file or symlink
exec('rm .git/info/exclude');
if (branchGitignores.indexOf(currentBranch) !== -1) {
exec(`ln -s ../../.gitignores/${currentBranch} .git/info/exclude`);
} else {
exec('ln -s ../../.gitignores/default .git/info/exclude');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment