Skip to content

Instantly share code, notes, and snippets.

@AzadGh95
Created December 16, 2024 07:42
Show Gist options
  • Save AzadGh95/d45902d750f6db716bd8e8fafed8abe3 to your computer and use it in GitHub Desktop.
Save AzadGh95/d45902d750f6db716bd8e8fafed8abe3 to your computer and use it in GitHub Desktop.
How to get rid of DS_Store files in Laravel?

To get rid of .DS_Store files in your Laravel project and prevent them from being added in the future, follow these steps:


1. Remove Existing .DS_Store Files

Run the following command in your project's root directory to delete all .DS_Store files:

find . -name ".DS_Store" -delete

This command searches for .DS_Store files in the current directory and its subdirectories and deletes them.


2. Prevent .DS_Store from Being Added

To avoid .DS_Store files being added to your Git repository in the future, add the following line to your .gitignore file (if it’s not already there):

.DS_Store

3. Remove .DS_Store from Git Tracking

If .DS_Store files are already tracked by Git, you need to untrack them. Run these commands:

git rm --cached $(find . -name ".DS_Store")
git commit -m "Remove .DS_Store files"

This removes .DS_Store files from the Git index but keeps them on your local machine.


4. Optional: Prevent Creation of .DS_Store

If you're on macOS and want to stop .DS_Store files from being created on network drives or in certain locations, you can disable them with this command:

defaults write com.apple.desktopservices DSDontWriteNetworkStores true

Then restart the Finder for the change to take effect:

killall Finder

(Note: This won't prevent .DS_Store files from being created on local drives, only network drives.)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment