美文网首页
git丢弃EOL差异

git丢弃EOL差异

作者: 2b75747cf703 | 来源:发表于2017-06-05 17:56 被阅读28次
    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);
            }
        }
    }
    

    相关文章

      网友评论

          本文标题:git丢弃EOL差异

          本文链接:https://www.haomeiwen.com/subject/idqwfxtx.html