How to handle this Git error?

Specifically, the .DS_Store file, I am on a mac, so of course I put this in my .gitignore. I'm not interested in the file at all. But for some reason, he is trying to get it out of the bare repo that I install as the server.

Updating 8e11f79..b315527 error: Your local changes to the following files would be overwritten by merge: .DS_Store config/wi-fi.txt web/.DS_Store Please, commit your changes or stash them before you can merge. Aborting 
+5
source share
1 answer

Since you received an error due to attraction, the damage has already been done: someone has already made the .DS_Store file on git . This, of course, should never happen, but it did.

You really don't want such files to be versioned, because

  • git will modify them when checking for commit, or, even worse, it will actively merge changes from someone else into a local .DS_Store when merging a branch, possibly creating a broken .DS_Store file. I have no idea what your OS does with the contents of these files, but it does not expect you to modify them in any way.

  • You will receive an error message when you try to check the version containing the .DS_Store file when your OS has changed it.

  • Non-Apple users will not like .DS_Store files clogging up your repository.

I would advise you to try to track down the origin of the file, because this information is central to solving this problem. Command

 git log --all -- .DS_Store 

gives you a list of all the .DS_Store that touched the .DS_Store file. These are the commits you need to rewrite in order to remove .DS_Store from your story.

Rewriting commits can, of course, be done using the large git filter-branch gun, but so far only the last commits that have not yet been merged can prevent git rebase -i from executing.

And of course, when you're done, put the .DS_Store in your .gitignore and check it out. This should prevent people from (accidentally) adding .DS_Store files in the future.

+3
source

Source: https://habr.com/ru/post/1233914/


All Articles