Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to add ._* in gitignore?

Tags:

git

macos

I am on a Mac developing an OS X app with some C/C++ code. I recently added some files to my repository and their duplicate files are showing up as ._name.

I looked up my .gitignore file and it has .DS_Store and few other filters but nothing preventing these ._ files.

Is this the right way to add ._* to my gitignore to prevent these irrelevant files going into repo?

like image 701
Ahmed Avatar asked Sep 08 '15 17:09

Ahmed


People also ask

Should I add .GIT to Gitignore?

While you could add these files to your . gitignore_global file, it's still important to have the local . gitignore file. If other developers push to the project later, or if you push to it from a different machine, you'll automatically use the local .

Does Gitignore get cloned?

gitignore is created, the file will still be part of the repository and therefore cloned. Even that's an overstatement: an entry in a . gitignore file is only considered when some file is untracked. A committed file, as (because) it is being checked out, automatically becomes tracked.


1 Answers

On Mac OS, the finder can in some cases create ._ files that hold some Mac OS specific file information. See https://apple.stackexchange.com/questions/14980/why-are-dot-underscore-files-created-and-how-can-i-avoid-them for details.

However these are OS specific files, and therefore should not be checked into version control anyway.

So a ._* line in your gitignore will not only ignore your duplicate ._name files, but the other files it might find that match that pattern need not be checked into version control anyway (apart from any files that you create yourself that match ._*. In that case you could add an exception in the .gitignore).

Other than that, there is nothing to be found of any other file extensions that start with ._. See e.g.

  • https://en.wikipedia.org/wiki/List_of_file_formats
  • https://en.wikipedia.org/wiki/Alphabetical_list_of_filename_extensions_(A%E2%80%93E)
  • https://en.wikipedia.org/wiki/Alphabetical_list_of_filename_extensions_(F%E2%80%93L)
  • https://en.wikipedia.org/wiki/Alphabetical_list_of_filename_extensions_(M%E2%80%93R)
  • https://en.wikipedia.org/wiki/Alphabetical_list_of_filename_extensions_(S%E2%80%93Z)

So yes, it is safe to ignore ._*.

like image 137
Tim Avatar answered Sep 30 '22 15:09

Tim