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

后端 未结 4 952
悲&欢浪女
悲&欢浪女 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:17

    If the file is supposed to never get into the repository, fix the problem and do it correctly...

    1. add the file/pattern to the .gitignore file
    2. delete the unwanted files from the repository
    3. commit to untrack the undesired file and commit .gitignore
    4. push the changes

    And you'll never have to deal with those unwanted files again because .gitignore will avoid future git adds of those files (unless --forced)

提交回复
热议问题