0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.