Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should website image files be included in GIT repository?

I have a website file/folder structure template to start using with git. It contains an empty .gitignore file inside the images folder, which leads me to my two part question:

1.) Will this empty .gitignore file ignore all the images located inside the images folder, or was it placed there to allow the empty folder to be added to the repository before any images were placed inside?

2.) Should website images be included in a git repository? To me, image files are edited and altered just the same as other files, and it would be beneficial to keep track of said changes over time.

What is considered best practice? What do you do, and why?

like image 325
stefmikhail Avatar asked May 01 '12 21:05

stefmikhail


People also ask

Can you store images in Git?

TLDR: if you can, use git-lfs to store images or other binary files in git.

Do you upload images to GitHub?

Upload images to GitHub. Create a new issue on GitHub. Drag an image into the comment field. Wait for the upload process to finish.

Can Git be used with images?

Raster images and music files make as much sense to Git as they would to you if you looked at the binary data contained in a . png or . wav file. So Git just takes all the data and makes a new copy of it, even if only one pixel changes from one photo to the next.

What should I not store in Git?

You shouldn't store credentials like usernames, passwords, API keys and API secrets. If someone else steals your credentials, they can do nasty things with it.


2 Answers

  1. In your case, the .gitignore allow git to "see" the directory. It could be any other file. Git doesn't store empty folder. You have to put this line into your .gitignore to tell to ignore all other files: !.gitignore
  2. There is no absolute response but I advise you to keep your images in the repository with the other files. Consider your git repository as your versionned website, images included. It will ease you if you want to automate your deployments. It will keep your website history consistent too. GIT handles images like any other files.
like image 51
noirbizarre Avatar answered Sep 30 '22 17:09

noirbizarre


Check out 'setup with binaries' and specifically 'git media' and 'git annex'. But, it is perfectly fine to use GIT directly with image files with one caveat - if you try 'git rebase' there can be a crash when comparing two large images.

like image 21
GoZoner Avatar answered Sep 30 '22 17:09

GoZoner