Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lohenyumnam/2b127b9c3d1435dc12a33613c44e6308 to your computer and use it in GitHub Desktop.
Save lohenyumnam/2b127b9c3d1435dc12a33613c44e6308 to your computer and use it in GitHub Desktop.

If .DS_Store was never added to your git repository, simply add it to your .gitignore file.

If you don't have one, create a file called


In your the root directory of your app and simply write


In it. This will never allow the .DS_Store file to sneak in your git.

if it's already there, write in your terminal:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

then commit and push the changes to remove the .DS_Store from your remote repo:

git commit -m "Remove .DS_Store from everywhere"

git push origin master

And now add .DS_Store to your .gitignore file, and then again commit and push with the 2 last pieces of code (git commit..., git push...)

Other Solution

If .DS_Store already committed:

find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch

To ignore them in all repository: (sometimes it named ._.DS_Store)

echo ".DS_Store" >> ~/.gitignore_global
echo "._.DS_Store" >> ~/.gitignore_global
echo "**/.DS_Store" >> ~/.gitignore_global
echo "**/._.DS_Store" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
Copy link

it work for me thank you very much.

Copy link

It worked really well for me too, ty =)

Copy link

Oh, thanks a lot

Copy link

LFClaro commented Dec 3, 2021

Just what I was looking for! Thank you so much for this.

Copy link

nk-vo commented May 15, 2022

thanks for this!

Copy link

This helped me, thanks a lot🙌

Copy link

abrizah commented Jun 20, 2022

Thanks! Perfection!

Copy link

muhdavi commented Jul 10, 2022

thanks, helpful!!!

Copy link


Copy link

njpl3 commented Sep 7, 2022

Worked perfectly, thank you!

Copy link

thank you

Copy link

nivel10 commented Dec 4, 2022

Thank you. Sir...!!!!

Copy link

Thank you!

Copy link

Worked without a flaw! Thanks

Copy link

Thank you!

Copy link

Thank you 👍🏻

Copy link

Thank you for the detailed help. It worked for me as soon as I ran the following command:

find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch

Copy link


Copy link

Thanks, buddy!

Copy link

Additionally, you might want to add these lines, to make sure your personal Xcode config is not proliferated:

User settings


Xcode 8 and earlier


Copy link


Copy link

It worked for me. Thank you!

Copy link

Helped to me add files in gitignore

Copy link

ivyzbot commented Aug 21, 2023

Many thanks for the clear clarification!

Copy link

Thanks for providing the step-by-step!

Copy link

Works great, thanks!

Copy link

opsquid commented Sep 10, 2023

Thank you! It saves my day.

Copy link

great, thanks

Copy link

Worked for me .Thanks alot for help

Copy link

Thank you. This worked.

Copy link

lgirao commented Mar 9, 2024

Thank you! Works for me :)

Copy link

royceno commented Mar 17, 2024

Thank you!

Copy link

Thank you so much!

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