Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is git only good for text files/source code? [duplicate]

A very noob question.

Is it also good to use git for my whole project (as kind of synchronization between different storages, version control is not the main point), including images, pdfs, Word documents, probably even some exe-files?

How does it track changes in pdfs, images, exe-files, if at all? If it stores the whole changed files simply because there's some difference with the HEAD version, the repository can become quite large after few commits.. Or does it still manage to save only the incremental changes in files other than text files?

The bottom line: is git good (or at least acceptable) for synchronization of big projects? For me it will be enough if it's not worse than Dropbox etc. (in terms of end result, GUI is not an issue).

like image 414
Omicron_Persei_11 Avatar asked Dec 03 '14 09:12

Omicron_Persei_11


People also ask

Does git only work with text files?

Non-text Files It is true that Git can handle these filetypes (which fall under the banner of “binary” file types). However, just because it can be done doesn't mean it should be done.

Does git work for all file types?

Git can be used for big projects, but you shouldn't check in generated files (like pdf, exe, etc). Add a . gitignore file (google for details) in which is written which files git should ignore.

What types of files can be stored in git?

Git can handle binary files just as well as text files. Instead of explicitly storing diffs, Git stores the entire previous revisions of files in the repository. The repository objects are then compressed to save space. Diffs are reconstructed on the fly whenever you ask for them.

Can git be used for binary files?

You can also use the Git attributes functionality to effectively diff binary files. You do this by telling Git how to convert your binary data to a text format that can be compared via the normal diff.


1 Answers

Git can see that you changed your non-text files, but you won't be able to get the best of git in that case. With text files you can see what is the actual difference between different versions / commits.

That being said, you could try this solution for image diffs in git. I am sure that there should be software to display differences between other file types, that you may need and that would make sens to check for differences.

Compared to dropbox, git should be better, because you can use commit messages that will say what was done in that particular change, and you can create feature branches; but it is a bit more complicated, due to its purpose, namely keeping track of source code differences between versions.

EDIT:

A̶n̶d̶ ̶n̶o̶,̶ ̶G̶i̶t̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶s̶a̶v̶e̶ ̶i̶n̶c̶r̶e̶m̶e̶n̶t̶a̶l̶ ̶c̶h̶a̶n̶g̶e̶s̶ ̶f̶o̶r̶ ̶n̶o̶n̶-̶t̶e̶x̶t̶ ̶f̶i̶l̶e̶s̶,̶ ̶b̶u̶t̶ ̶n̶e̶i̶t̶h̶e̶r̶ ̶d̶o̶e̶s̶ ̶d̶r̶o̶p̶b̶o̶x̶,̶ ̶a̶s̶ ̶f̶a̶r̶ ̶a̶s̶ ̶I̶ ̶k̶n̶o̶w̶.̶

It looks like git is storing non-text files as character strings, so yes it should only keep track of differences. Therefore, any good difftool like meld or Beyond Compare should be able to tell the difference between two images, for instance. For instance, I was able to see the differences between two png images with Beyond Compare.

It also seems to do a good job with PDF files, but, like exe files, you should not track those file types with version control. Instead of PDFs, keep track of their source code - for instance LaTeX files (which are plain text). Due to their nature, compiled files, like exe files are not suited for version control. The reason for this is that even if you edit directly into the character string of the file, you won't be able to accomplish much - you are supposed to edit the source code.

like image 80
DrKaoliN Avatar answered Oct 09 '22 00:10

DrKaoliN