Skip to content

Commit

Permalink
feat: add git alias.coc as "git checkout -- . && git clean -df"
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu0605 committed Jan 16, 2024
1 parent 90a6e6f commit 4c2901a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ git config --global alias.alias "config --get-regexp ^alias\."
# 必須是 Windows 平台才會執行以下設定
git config --global alias.ignore '!gi() { curl -sL https://www.gitignore.io/api/$@ ;}; gi'
git config --global alias.iac '!giac() { git init -b main && git add . && git commit -m 'Initial commit' ;}; giac'
git config --global alias.coc '!gcoc() { git checkout -- . && git clean -df ;}; gcoc'
git config --global alias.cz '!npx cz'
git config --global alias.changelog "!conventional-changelog -p angular -i CHANGELOG.md -s"

# 必須是 Linux/macOS 平台才會執行以下設定
git config --global alias.ignore '!'"gi() { curl -sL https://www.gitignore.io/api/\$@ ;}; gi"
git config --global alias.iac '!'"giac() { git init -b main && git add . && git commit -m 'Initial commit' ;}; giac"
git config --global alias.coc '!'"gcoc() { git checkout -- . && git clean -df ;}; gcoc"
git config --global alias.cz '!'"npx cz"
git config --global alias.changelog '!'"conventional-changelog -p angular -i CHANGELOG.md -s"

Expand Down
6 changes: 6 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ const fs = require('fs');
await cmd("git config --global alias.iac '!'\"giac() { git init -b main && git add . && git commit -m 'Initial commit' ;}; giac\"");
}

if (os === 'win32') {
await cmd("git config --global alias.coc \"!gcoc() { git checkout -- . && git clean -df ;}; gcoc\"");
} else {
await cmd("git config --global alias.coc '!'\"gcoc() { git checkout -- . && git clean -df ;}; gcoc\"");
}

if (os === 'win32' && fs.existsSync('C:/PROGRA~1/TortoiseGit/bin/TortoiseGitProc.exe')) {
await cmd("git config --global alias.tlog \"!start 'C:\\PROGRA~1\\TortoiseGit\\bin\\TortoiseGitProc.exe' /command:log /path:.");
}
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"Cgreen",
"Creset",
"dcommit",
"gcoc",
"giac",
"leoli",
"longpaths",
Expand Down

0 comments on commit 4c2901a

Please sign in to comment.