在我的项目中,我使用的操作系统不同,一台是Mac,第二台是Windows。当我使用git时,所有更改都显示为整个文档更改。原因是这两个OS的行尾不同。我阅读了此https://help.github.com/articles/dealing-with-line-endings/并.gitattributes在根文件夹中创建了一个文件,但问题仍然存在。这是我的.gitattributes文件:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.css text
*.html text
*.js text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用,因为我之前曾尝试过对该文件进行很多配置。
我添加 & 提交 & 推送了几个 PNG 文件到我的 git repo 中,但不幸的是,我有一个不正确的 .gitattributes 文件,如下所示:
* text
# no settings for PNG files
Run Code Online (Sandbox Code Playgroud)
PNG 文件被 git 视为文本文件。现在我无法再打开它们,而且我也丢失了它们的原始副本。有什么办法可以恢复它们吗?谢谢!
更新:.gitattributes添加 PNG 文件时已经在 repo 中。这意味着我无法在提交历史记录中找到PNG 文件的良好状态。所有提交都是在 Windows 上进行的。
我在这里看到代码
https://gist.github.com/Srfigie/77b5c15bc5eb61733a74d34d10b3ed87
#Image
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.psd filter=lfs diff=lfs merge=lfs -text
*.ai filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
Run Code Online (Sandbox Code Playgroud) 我用Python编写了一个程序,并使用Bootstrap作为它的前端.
当我在GitHub上传目录时,它显示该项目是90%的JavaScript,只有7.5%的Python.我知道这是因为Bootstrap文件夹中的JS目录而发生的.
我需要将Python显示为repo的主要项目语言.
我做了一些研究,并了解到将文件添加.gitattributes到项目中是一种解决方案,但我不知道在该文件中添加什么来让Github在评估项目的主要语言时忽略JavaScript.
我查看了官方.gitattributes手册页,但找不到直接解决此问题的方法.
这是回购的样子
编辑:所有的CSS和JS文件都在static/文件夹中,所以我.gitattributes在repo中添加了一个文件并添加static/* linguist-vendored到第一行,但是repo仍然将JS显示为90%的语言.