Skip to content

Commit

Permalink
feat: add git push configuration and git tag alias
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu0605 committed Feb 7, 2024
1 parent 3c6f3f6 commit 9328854
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ git config --global color.status auto
git config --global color.branch auto

git config --global pull.rebase true
git config --global push.followTags true

git config --global alias.co checkout
git config --global alias.ss status
Expand Down Expand Up @@ -69,6 +70,9 @@ git config --global alias.iac '!'"giac() { git init -b main && git add . && git
# 快速清理工作目錄並復原已追蹤的檔案的指令
git config --global alias.coc '!'"gcoc() { git checkout -- . && git clean -df ;}; gcoc"

# 快速新增標籤的指令
git config --global alias.taga '!'"gtaga() { git tag -a $1 -m "$1" ;}; gtaga"

# Windows 平台專用 TortoiseGit 日誌指令
git config --global alias.tlog "!start 'C:\\PROGRA~1\\TortoiseGit\\bin\\TortoiseGitProc.exe' /command:log /path:."

Expand Down
10 changes: 10 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ const fs = require('fs');
// Git pull configuration
await cmd('git config --global pull.rebase true');

// Git push configuration
await cmd('git config --global push.followTags true');

// Git aliases for basic commands
await cmd('git config --global alias.co checkout');
await cmd('git config --global alias.ss status');
Expand Down Expand Up @@ -107,6 +110,13 @@ const fs = require('fs');
await cmd('git config --global alias.coc \'!\'"gcoc() { git checkout -- . && git clean -df ;}; gcoc"');
}

// Git tag alias configuration
if (os === 'win32') {
await cmd('git config --global alias.taga "!gtaga() { git tag -a "$1" -m "$1" ;}; gtaga"');
} else {
await cmd('git config --global alias.taga \'!\'"gtaga() { git tag -a "$1" -m "$1" ;}; gtaga"');
}

// TortoiseGit log alias configuration for Windows
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
3 changes: 3 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
"dcommit",
"gcoc",
"giac",
"gtaga",
"leoli",
"longpaths",
"oneline",
"PROGRA",
"pushf",
"quotepath",
"SETX",
"taga",
"tlog",
"willh"
],
Expand Down

0 comments on commit 9328854

Please sign in to comment.