Created
September 3, 2016 10:36
-
-
Save atfzl/2eb06c96cedb2d8c22d707a31a12ac6e to your computer and use it in GitHub Desktop.
use branch specific git ignore configs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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