Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save faultyagatha/e75eb1126273cc4301deb39d84f95f4b to your computer and use it in GitHub Desktop.
Save faultyagatha/e75eb1126273cc4301deb39d84f95f4b to your computer and use it in GitHub Desktop.

Revisions

  1. @lohenyumnam lohenyumnam revised this gist Mar 23, 2018. 1 changed file with 34 additions and 0 deletions.
    34 changes: 34 additions & 0 deletions Add DS_Store into .gitignore for the sub directory.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,37 @@


    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
  2. @lohenyumnam lohenyumnam created this gist Mar 23, 2018.
    14 changes: 14 additions & 0 deletions Add DS_Store into .gitignore for the sub directory.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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
    ```