How to ignore a file or directory in git, be it tracked, untracked or even part of commit

后端 未结 4 950
悲&欢浪女
悲&欢浪女 2021-01-19 23:29

I want to completely ignore a part of a git repository. The directory is currently tracked in the repository and I\'d like to ensure that

  • whenever anybody chan
4条回答
  •  太阳男子
    2021-01-20 00:05

    All answers above fail to handle branches that had split off before gitignoring and removing the unwanted files, and contain commits with changes to those files. Such branches will just sit there waiting for an opportunity to wreak havoc upon a merge or rebase.

    Practically speaking, there is no solution other than recreating all repos from scratch with the unwanted files in .gitignore from the very start. Un-tracking stuff is simply thoroughly broken in git.

    Git fails to model the simple reality where users are not effing clairvoyant, and just plainly don't know what kind of do-not-track (temporaries | intermediates | caches | whatever) will be created by a framework that hasn't even been written yet, but will be incorporated into the project at some point in the future.

提交回复
热议问题