Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

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

.gitignore

In your the root directory of your app and simply write

**/.DS_Store

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
@chengliu-LR
Copy link

chengliu-LR commented Mar 18, 2021

Thank you for the clear instructions!

@onns
Copy link

onns commented Apr 24, 2021

Thank you for the instruction and I wanna know if only **/.DS_Store is enough for the ignore files, as it says in gitignore documentation that A leading "**" followed by a slash means match in all directories.

@PASSIONCORNERS
Copy link

PASSIONCORNERS commented May 14, 2021

Thank you for the clear instruction, great help !

@SUCHITRAGIRI
Copy link

SUCHITRAGIRI commented Jun 29, 2021

Helpful!!
Thank you so much:)

@aspain
Copy link

aspain commented Aug 10, 2021

much appreciated, very clear instructions

@maprangsoft
Copy link

maprangsoft commented Aug 14, 2021

it work for me thank you very much.

@JVBravoo
Copy link

JVBravoo commented Aug 19, 2021

It worked really well for me too, ty =)

@hflexgrig
Copy link

hflexgrig commented Nov 30, 2021

Oh, thanks a lot

@LFClaro
Copy link

LFClaro commented Dec 3, 2021

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

@nk-vo
Copy link

nk-vo commented May 15, 2022

thanks for this!

@vivek1938932
Copy link

vivek1938932 commented Jun 16, 2022

This helped me, thanks a lot🙌

@abrizah
Copy link

abrizah commented Jun 20, 2022

Thanks! Perfection!

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