Files
huishou/git-push.js
T
2026-07-27 13:38:37 +08:00

31 lines
992 B
JavaScript

const { execSync } = require('child_process');
const fs = require('fs');
const gitPath = 'D:\\Git\\bin\\git.exe';
try {
console.log('=== Remove lock file ===');
const lockFile = 'D:\\Trae\\huishou\\.git\\index.lock';
if (fs.existsSync(lockFile)) {
fs.unlinkSync(lockFile);
console.log('Lock file removed');
}
console.log('=== Add all files ===');
execSync(`${gitPath} add .`, { stdio: 'inherit', cwd: __dirname });
console.log('=== Commit code ===');
execSync(`${gitPath} commit -m "Initial commit"`, { stdio: 'inherit', cwd: __dirname });
console.log('=== Add remote ===');
execSync(`${gitPath} remote add origin git@git.torchcloud.cn:jiapengyu/huishou.git`, { stdio: 'inherit', cwd: __dirname });
console.log('=== Push to remote ===');
execSync(`${gitPath} push -u origin master`, { stdio: 'inherit', cwd: __dirname });
console.log('=== Success ===');
} catch (error) {
console.error('=== Failed ===');
console.error(error.message);
}