Removing .xcuserstate and DS_Store files from git

前端 未结 2 1304
自闭症患者
自闭症患者 2020-12-23 12:24

In Xcode I noticed that .DS_Store and *.xcuserstate always change and don\'t need to be commited. So, I wrote a .gitignore file that contains this:

.DS_Store         


        
相关标签:
2条回答
  • 2020-12-23 12:54

    Try git update-index --assume-unchanged *.xcuserstate .DS_Store and see if it helps

    0 讨论(0)
  • 2020-12-23 13:12

    You need to commit your change after removing them from the staging area.

    As you did already, run:

    $ git rm --cached path/to/.DS_Store
    $ git rm --cached *.xcuserstate
    

    Note, you may have some in other directories, so you may need several invocations to get them all. At this point, your removals are staged in the index, but there's still more to do: add your .gitignore, and commit the final result:

    $ git add .gitignore
    $ git commit -m "Remove and ignore .xcuserstate and .DS_Store files."
    

    Now they'll be removed from the repository, and ignored in the future. Note: this will remove the files for other people, even though you used git rm --cached locally. Unfortunately, there isn't much you can do about this. Also, the files are still in your history, so depending on what you do, you may see them in other branches until things get merged and all your branches are based on something that has the new commit.

    0 讨论(0)
提交回复
热议问题