Stop tracking a file in git - without having it deleted either locally or on pull

后端 未结 2 829
伪装坚强ぢ
伪装坚强ぢ 2021-01-22 12:45

I want to ignore a file/directory tree that was previously tracked - ignore it forever but have it not being deleted on a pull - just have it ignored o

相关标签:
2条回答
  • 2021-01-22 13:45

    I had kind of the same problem, I used git rm --cached <file> and it worked locally but once I made a push to the remote server it deleted also the files, and I did not want that.Then I found git update-index --assume-unchanged <file> and it ignores the local changes and does not delete it from the remote server, worked like a charm!

    0 讨论(0)
  • 2021-01-22 13:49

    This is not possible. To prevent new changes from being tracked, you need to remove the file from the repository (using git rm or git rm --cached). This adds a change to the commit that removes the file. When that change is then applied in other repositories, the remove action is performed, resulting in the file being removed.

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