Skip to content

Commit

Permalink
feat: New shortpost - gitattributes-linguist
Browse files Browse the repository at this point in the history
  • Loading branch information
riceball-tw committed Jun 25, 2024
1 parent 6c141e5 commit a9767d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/content/shortPost/gitattributes-linguist/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
titleTC: '在 .gitattributes 設置 Linguist 改變專案語言統計'
publishDate: 2024-06-26
category: 'GitHub'
social:
threads: 'https://www.threads.net/@webdong.dev/post/C8W-bQYBOav'
---

[Linguist](https://github.com/github-linguist/linguist) 用於統計 GitHub 倉庫中的語言比例。

像是 [TypeScript 專案](https://github.com/microsoft/TypeScript/blob/main/.gitattributes)就特意將所有 `.js` 檔案統計替換成 TypeScript,才會出現整個專案由 `99.9%` TypeScript 構成的統計結果。

![TypeScript 語言統計](./typescript-language.webp)

```bash
*.js linguist-language=TypeScript
```

其他用途像是排除特定的檔案或目錄於統計中,可以幫助我們把不重要的資訊排除,讓真正的專案語言統計更加準確(在 GitHub 倉庫顯示上)。

```bash
# 排除特定檔案
*.md linguist-vendored

# 排除特定目錄
docs/* linguist-vendored
```
Git LFS file not shown

0 comments on commit a9767d6

Please sign in to comment.