How can I Remove .DS_Store files from a Git repository ?

How can I Remove .DS_Store files from a Git repository ?

Asked on December 27, 2018 in Git.
Add Comment


  • 3 Answer(s)

    Eliminate the following  existing files from the repository:

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

    include the line:

    .DS_Store
    

    Create the file .gitignore to found at the top level to repository the  easily for command the top directory .

    echo .DS_Store >> .gitignore
    

    Other

    git add .gitignore
    git commit -m '.DS_Store banished!'
    

     

    Answered on December 27, 2018.
    Add Comment

    Updating with git rm, not failing on files making it paste-able to  generically for user:

    # remove any existing files from the repo, skipping over ones not in repo
    find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
    # specify a global exclusion list
    git config --global core.excludesfile ~/.gitignore
    # adding .DS_Store to that list
    echo .DS_Store >> ~/.gitignore
    
    Answered on December 27, 2018.
    Add Comment

    Globally ignore these file from all the  git repos  system  , create to done the global gitignore file to tackle the isssue:

    vi ~/.gitignore_global
    

    Including the rule for ignore the file:

    # Compiled source #
    ###################
    *.com
    *.class
    *.dll
    *.exe
    *.o
    *.so
    # Packages #
    ############
    # it's better to unpack these files and commit the raw source
    # git has its own built in compression methods
    *.7z
    *.dmg
    *.gz
    *.iso
    *.jar
    *.rar
    *.tar
    *.zip
    # Logs and databases #
    ######################
    *.log
    *.sql
    *.sqlite
    # OS generated files #
    ######################
    .DS_Store
    .DS_Store?
    ._*
    .Spotlight-V100
    .Trashes
    ehthumbs.db
    Thumbs.db
    

    Currently add this file to global git configuration:

    git config --global core.excludesfile ~/.gitignore_global
    

    Check:

    To attached the application assets you need to remove the icons.

    Answered on December 27, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.