git丢弃EOL差异
2017-06-05 本文已影响28人
2b75747cf703
function discardGitEOL()
{
const execSync = require('child_process').execSync;
let options = {encoding: "utf8"};
let git = "\"C:/Program Files (x86)/SmartGit/git/bin/git.exe\"";
let stdout = execSync(`${git} status --short`, options);
stdout = stdout.split("\n");
for(let i = 0; i < stdout.length;i++)
{
let status = stdout[i].substring(1, 2);
let filename = stdout[i].substring(3);
if(status != "M")
continue;
console.log(`git diff ${filename}`);
let diff = execSync(`${git} diff ${filename}`, options);
if(diff == "")
{
console.log(`git checkout -- ${filename}`);
execSync(`${git} checkout -- ${filename}`, options);
}
}
}