How can binary files be ignored in git
using the .gitignore
file?
Example:
$ g++ hello.c -o hello
The
You may try in your .gitignore
:
*
!*.c
This approach has many disadvantages, but it's acceptable for small projects.
I don't know any other solution but adding them one by one to .gitignore
.
A crude way to test is to grep the file command's output:
find . \( ! -regex '.*/\..*' \) -type f | xargs -n 1 file | egrep "ASCII|text"
EDIT
Why don't you simply name you executable hello.bin
?
If you follow these commands on your .gitignore file and files still seems to appear you may want to try:
git rm --cached FILENAME
After that, add your .gitignore, commit and push. Took me 40 minutes to understand that, hope this helps to newbies like me
Binary files are often without extensions. If this is your case try this:
*
!/**/
!*.*
REF: https://stackoverflow.com/a/19023985/1060487
I created a .gitignore file with two entries in GOPATH directory.
/bin
/pkg
It ignore all the compiled developments, currently.
# Ignore all
*
# Unignore all with extensions
!*.*
# Unignore all dirs
!*/
### Above combination will ignore all files without extension ###
# Ignore files with extension `.class` & `.sm`
*.class
*.sm
# Ignore `bin` dir
bin/
# or
*/bin/*
# Unignore all `.jar` in `bin` dir
!*/bin/*.jar
# Ignore all `library.jar` in `bin` dir
*/bin/library.jar
# Ignore a file with extension
relative/path/to/dir/filename.extension
# Ignore a file without extension
relative/path/to/dir/anotherfile