I want to add shell scripts (".sh") into a git repository. But when viewing them in the git web interface it recognises them as binary files. Therefore I can not view them online or see diffs between different commits.
Is there a way to tell git how to handle these shell scripts?
You can tell git that these files are text files using the .gitattributes
file. The simplest way is to say that all .sh
files are text. Put this in a .gitattributes
file in your repository root:
*.sh text
This might not fix your issue, though. When you say 'git web interface', do you mean 'Github'? I couldn't find any documentation about whether Github uses the .gitattributes
file when determining the file type. But this will let you run git diff
on your local repository, at least.
There's some more documentation about .gitattributes
in the Pro Git book. That approaches things in the other way, though: making binary files available as text, for meaningful diffs.