trs-tag
Version:
a tool for easy update package.version and create git tag / push git tag
346 lines (263 loc) • 8.98 kB
JavaScript
var inquirer = require('inquirer');
var shell = require('shelljs');
var catList = [
'代码库' ,
'配置',
'增删改文件',
'代码提交',
'分支',
'标签',
'查看信息',
'远程同步',
'撤销',
'其它'
];
inquirer.prompt([{
type: 'list',
name: 'cat',
message: '请选择命令类型',
choices: catList,
pageSize: 10
}]).then((answers) => {
switch (answers.cat) {
case '代码库':
showRepo();
break;
case '配置':
showConfig();
break;
case '增删改文件':
showFile();
break;
case '代码提交':
showCZ();
break;
case '分支':
showBranch();
break;
case '标签':
showTag();
break;
case '查看信息':
showLog();
break;
case '远程同步':
showRemote();
break;
case '撤销':
showBack();
break;
case '其它':
showOther();
break;
}
});
function showRepo() {
shell.echo(`
$ git init
$ git init [project-name]
$ git clone [url]
`);
}
function showConfig() {
shell.echo(`
$ git config --list
$ git config -e [--global]
$ git config [--global] user.name "[name]"
$ git config [--global] user.email "[email address]"
`);
}
function showFile() {
shell.echo(`
$ git add [file1] [file2] ...
$ git add [dir]
$ git add .
$ git add -p
$ git rm [file1] [file2] ...
$ git rm --cached [file]
$ git mv [file-original] [file-renamed]
`);
}
function showCZ() {
shell.echo(`
$ git commit -m [message]
$ git commit [file1] [file2] ... -m [message]
$ git commit -a
$ git commit -v
$ git commit --amend -m [message]
$ git commit --amend [file1] [file2] ...
`);
}
function showBranch() {
shell.echo(`
$ git branch
$ git branch -r
$ git branch -a
$ git branch [branch-name]
$ git checkout -b [branch]
$ git branch [branch] [commit]
$ git branch --track [branch] [remote-branch]
$ git checkout [branch-name]
$ git checkout -
$ git branch --set-upstream [branch] [remote-branch]
$ git merge [branch]
$ git cherry-pick [commit]
$ git branch -d [branch-name]
$ git push origin --delete [branch-name]
$ git branch -dr [remote/branch]
`);
}
function showTag() {
shell.echo(`
$ git tag
$ git tag [tag]
$ git tag [tag] [commit]
$ git tag -d [tag]
$ git push origin :refs/tags/[tagName]
$ git show [tag]
$ git push [remote] [tag]
$ git push [remote] --tags
$ git checkout -b [branch] [tag]
`);
}
function showLog() {
shell.echo(`
$ git status
$ git log
$ git log --stat
$ git log -S [keyword]
$ git log [tag] HEAD --pretty=format:%s
$ git log [tag] HEAD --grep feature
$ git log --follow [file]
$ git whatchanged [file]
$ git log -p [file]
$ git log -5 --pretty --oneline
$ git shortlog -sn
$ git blame [file]
$ git diff
$ git diff --cached [file]
$ git diff HEAD
$ git diff [first-branch]...[second-branch]
$ git diff --shortstat "@{0 day ago}"
$ git show [commit]
$ git show --name-only [commit]
$ git show [commit]:[filename]
$ git reflog
`);
}
function showRemote() {
shell.echo(`
$ git fetch [remote]
$ git remote -v
$ git remote show [remote]
$ git remote add [shortname] [url]
$ git pull [remote] [branch]
$ git push [remote] [branch]
$ git push [remote] --force
$ git push [remote] --all
`);
}
function showBack() {
shell.echo(`
$ git checkout [file]
$ git checkout [commit] [file]
$ git checkout .
$ git reset [file]
$ git reset --hard
$ git reset [commit]
$ git reset --hard [commit]
$ git reset --keep [commit]
$ git revert [commit]
$ git stash
$ git stash pop
`);
}
function showOther() {
shell.echo(`
$ git archive
`);
}