File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ ### 修改Github上项目语言显示问题
2+
3+ #### 问题
4+ 最近将自己写的博客放到github上了。由于使用了富文本编辑器、jQuery、Bootstrap等第三方插件,导致js、css等代码远远超过你自己写的代码
5+
6+ 于是也就成这样了
7+
8+ ![ ] ( https://github.com/scalad/Note/blob/master/Git_Language_Show/image/vQz6FjB.png )
9+
10+ 而且这里也显示JavaScript
11+
12+ ![ ] ( https://github.com/scalad/Note/blob/master/Git_Language_Show/image/EBFZJrr.png )
13+
14+ 这样的情况很不能忍,尤其对于强迫症来说。而且github也没有bitbucket项目语言的设置
15+
16+ 搜索了一下发现github是使用 Linguist 来detect所使用的语言。 Linguist 是什么鬼我也不了解,大致就是通过统计哪种语言代码数量最多的作为当前项目主语言。这样很不公平有木有,像Scala这种支持函数式编程而且语法简洁的语言,代码量完全拼不过其他语言
17+
18+ #### 解决
19+
20+ 解决起来也简单,有2种方法
21+
22+ #### 1、使用外链接
23+
24+ 将项目中的静态文件如jQuery、Bootstrap等放到别处用连接导入即可
25+
26+ #### 2、使用 .gitattributes 配置文件
27+
28+ 具体就是在项目根目录添加文件名为.gitattributes的文本文件,写入
29+
30+ *.js linguist-language=Scala
31+ *.css linguist-language=Scala
32+ *.html linguist-language=Scala
33+
34+ 意思就是将.js、css、html当作Scala语言来统计
35+
36+ 另外,说一下,在windows系统中并不好直接创建名为 .gitattributes 的文件,会提示:
37+
38+ ![ ] ( https://github.com/scalad/Note/blob/master/Git_Language_Show/image/u2UVna.png )
39+
40+ 那么只需要用命令行创建就行了,或者使用VI也是可以的:
41+
42+ touch .gitattributes
You can’t perform that action at this time.
0 commit comments