{"id":29698466,"url":"https://github.com/leoliu0605/npm-git-setup","last_synced_at":"2026-02-05T21:03:19.627Z","repository":{"id":212036298,"uuid":"730490972","full_name":"leoliu0605/npm-git-setup","owner":"leoliu0605","description":"A Quick Git Setup Tool ( npx @leoli0605/git-setup )","archived":false,"fork":false,"pushed_at":"2026-02-03T05:45:33.000Z","size":66,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-03T18:48:07.057Z","etag":null,"topics":["git","git-config","git-setup"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@leoli0605/git-setup","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leoliu0605.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-12T03:24:24.000Z","updated_at":"2026-02-03T05:47:46.000Z","dependencies_parsed_at":"2023-12-12T08:23:04.713Z","dependency_job_id":"73142120-82f9-4b25-bb57-cdd4cafefc41","html_url":"https://github.com/leoliu0605/npm-git-setup","commit_stats":null,"previous_names":["leoli0605/npm-git-setup","dinosaurialab/npm-git-setup","leoliu0605/npm-git-setup"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/leoliu0605/npm-git-setup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoliu0605%2Fnpm-git-setup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoliu0605%2Fnpm-git-setup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoliu0605%2Fnpm-git-setup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoliu0605%2Fnpm-git-setup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leoliu0605","download_url":"https://codeload.github.com/leoliu0605/npm-git-setup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leoliu0605%2Fnpm-git-setup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29134243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T20:50:26.975Z","status":"ssl_error","status_checked_at":"2026-02-05T20:49:26.082Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","git-config","git-setup"],"created_at":"2025-07-23T10:07:01.477Z","updated_at":"2026-02-05T21:03:19.064Z","avatar_url":"https://github.com/leoliu0605.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-setup\r\n\r\n本工具是基於 [@willh/git-setup](https://www.npmjs.com/package/@willh/git-setup) 的開源專案，添加修改成符合個人的使用習慣。\r\n主要功能為全自動設定 Git 版控環境，並且跨平台支援 Windows, Linux, macOS 等作業系統的命令列環境，尤其針對中文環境經常會出現亂碼的問題都會完整的解決。\r\n\r\n## 先決條件\r\n\r\n- [Node.js](https://nodejs.org/en/) 10.13.0 以上版本\r\n- [Git](https://git-scm.com/) 任意版本 (建議升級到最新版)\r\n\r\n## 使用方式\r\n\r\n```sh\r\nnpx @leoli0605/git-setup\r\n```\r\n\r\n- 設定過程會詢問你的 `user.name` 與 `user.email` 資訊\r\n  - Email 會進行格式驗證，格式錯誤會拒絕設定下去\r\n- 所有 Git 設定都會以 `--global` 為主 (`~/.gitconfig`)\r\n- Windows 平台會自動設定 `LC_ALL` 與 `LANG` 使用者環境變數\r\n  - Linux, macOS 平台會提醒進行設定\r\n\r\n\u003e [!TIP]\r\n\u003e 可以使用下列指令快速清除已經存在的 Git 別名設定：\u003cbr\u003e\r\n\u003e - Windows:\u003cbr\u003e\r\n\u003e `git config --global --get-regexp '^alias\\.' | % { git config --global --unset ($_.Split(\" \")[0]) }`\u003cbr\u003e\r\n\u003e - Unix:\u003cbr\u003e\r\n\u003e `git config --global --get-regexp ^alias\\. | cut -d ' ' -f1 | xargs -L1 git config --global --unset`\r\n\r\n## 設定內容\r\n\r\n```sh\r\ngit config --global user.name \"${name}\"\r\ngit config --global user.email \"${email}\"\r\n\r\ngit config --global core.editor \"vim\"\r\ngit config --global core.autocrlf false\r\ngit config --global core.quotepath false\r\ngit config --global core.longpaths true\r\ngit config --global svn.rmdir true\r\n\r\ngit config --global init.defaultBranch main\r\n\r\ngit config --global help.autocorrect 30\r\n\r\ngit config --global color.diff auto\r\ngit config --global color.status auto\r\ngit config --global color.branch auto\r\n\r\ngit config --global pull.rebase true\r\ngit config --global pull.autostash true\r\ngit config --global push.followTags true\r\n\r\ngit config --global alias.list '!'\"git --no-pager config --global --list\"\r\ngit config --global alias.co checkout\r\ngit config --global alias.ss status\r\ngit config --global alias.sss \"status -s\"\r\ngit config --global alias.br branch\r\ngit config --global alias.pf \"push --force-with-lease\"\r\n\r\ngit config --global alias.ci \"commit --allow-empty-message\"\r\ngit config --global alias.ca \"commit --amend -C HEAD\"\r\n\r\ngit config --global alias.lo \"log --oneline\"\r\ngit config --global alias.ls \"log --show-signature\"\r\ngit config --global alias.ll \"log --pretty='%C(Yellow)%h%x09%C(reset)(%ci) %C(Cyan)%an: %C(reset)%s' --date=short\"\r\ngit config --global alias.lg \"log --graph --pretty=format:'%Cred%h%Creset %ad |%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset [%Cgreen%an%Creset]' --abbrev-commit --date=short\"\r\n\r\ngit config --global alias.alias \"config --get-regexp ^alias\\.\"\r\n\r\n# 跨平台的 .gitignore 快速設定指令\r\ngit config --global alias.ignore '!'\"gi() { curl -sL https://www.gitignore.io/api/\\$@ ;}; gi\"\r\n\r\n# 快速初始化 Git 庫並做第一次提交的指令\r\ngit config --global alias.iac '!'\"giac() { git init -b main \u0026\u0026 git add . \u0026\u0026 git commit -m 'Initial commit' ;}; giac\"\r\n\r\n# 快速清理工作目錄並復原已追蹤的檔案的指令\r\ngit config --global alias.cc '!'\"gcc() { git checkout -- . \u0026\u0026 git clean -df ;}; gcc\"\r\n\r\n# 快速新增標籤的指令\r\ngit config --global alias.tg '!'\"gtg() { git tag -a \\\"\\$1\\\" -m \\\"\\$1\\\" ;}; gtg\"\r\n\r\n# Windows 平台專用 TortoiseGit 日誌指令\r\ngit config --global alias.tlog \"!start 'C:\\\\PROGRA~1\\\\TortoiseGit\\\\bin\\\\TortoiseGitProc.exe' /command:log /path:.\"\r\n\r\n# 快速使用 Commitizen 進行提交的指令，請先執行 `npm install -g commitizen`\r\ngit config --global alias.cz '!'\"npx cz\"\r\n\r\n# 快速產生 CHANGELOG.md 檔案的指令，請先執行 `npm install -g conventional-changelog-cli`\r\ngit config --global alias.changelog '!'\"conventional-changelog -p angular -i CHANGELOG.md -s -r 0\"\r\n```\r\n\r\n## 提供建議\r\n\r\n如果您對本工具有任何想法，歡迎到[這裡](https://github.com/leoliu0605/npm-git-setup/issues)留言討論！\r\n\r\n## 作者資訊\r\n\r\n- **LeoLiu**\r\n- 部落格：https://miscellaneous.im/blog/\r\n\r\n## 相關連結\r\n\r\n- [2.7 Git 基礎 - Git Aliases](https://git-scm.com/book/zh-tw/v2/Git-%E5%9F%BA%E7%A4%8E-Git-Aliases)\r\n- [Creating CLI Executable global npm module](https://medium.com/@thatisuday/creating-cli-executable-global-npm-module-5ef734febe32)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoliu0605%2Fnpm-git-setup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleoliu0605%2Fnpm-git-setup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleoliu0605%2Fnpm-git-setup/lists"}