svmiller / steveproj

An R package for getting academic projects/papers started.
http://svmiller.com/steveproj
30 stars 3 forks source link

Template Gitignore/ Gitattributes #2

Closed medewitt closed 3 years ago

medewitt commented 3 years ago

Something to think about adding. within the project so that newbies don't accidently commit something they shouldn't or start tracking changes on a binary file that will blow their .git up.

.gitattributes

# Source files
# ----
*.Rdata binary
*.RData binary
*.rda   binary
*.rdb   binary
*.rds   binary
*.Rd    text
*.Rdx   binary
*.Rmd     text
*.R       text
*.Rproj text
*.jpg  binary
*.gif  binary
*.png  binary
*.RDA  binary
*.RDS  binary
svmiller commented 3 years ago

This is mostly own for my education, but if I understand correctly, the .gitattributes file would ignore, initially, whatever files first came with it when the Git repo was first initiated. Is that about right? I could see that as a useful addition but I also want to make sure I understand what it's doing myself.

medewitt commented 3 years ago

Right, so git will ignore those extensions/files in the .gitignore and for those that are to be tracked the .gitattributes tells git how to track them.

If you tell git that a file is a binary, it won't try to do a line by line version/diff on it and you get caught in git hell (where you have conflicting binaries). There are loads of special options that one can use to specify how to diff on different file extensions (e.g. with word you can diff the text using docx2txt).