.gitignore file, where should I put it in my xcode project?

后端 未结 6 2255
无人共我
无人共我 2021-01-29 22:04

I want git to ignore my UserInterfaceState.xcuserstate file in my XCode4 project, but where should I put the .gitignore file?, is it inside the .

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-29 22:20

    There are there approaches to ignore files in git:

    1. Global git ignore: - In this approach your custom rules will be applied to every git directory in your machine. Usually this file might be created under ~/.gitignore_global path. This approach good if you want to exclude some type files which is generated by OS or any other logging, cashing and etc. tools.
    2. Per-repository git ignore: - In this approach your custom rules will be applied to specific git directory in your machine. Local per-repository rules can be added to the .git/info/exclude file in your repository. The rules specified under this file will not be committed, which means it will not be shared with others. Generally this approach useful to prevent committing of locally generated files. For example, for files created by your editor.
    3. Per path git ignore: - In this case your custom rules will be applied to specific git repositories sub path. You can create .gitignore in any sub path of your specific repository. This approach usually used to ignore some types of file only under specific folder of specific repository. While this files can be added to version controlling by other paths and other repositories.

    So, My suggest to you is, if you want to ignore your specific file (UserInterfaceState.xcuserstate) in your all repositories the best approach is to use global git ignore approach. However if your file is generated only in specific repository you can use per-repository git ignore approach.

    For more information you can read this great blog post. And there per language specific git ignore rules can be founded here. And you can auto generate general git ignore rules for specific language, tool or os using this web site.

提交回复
热议问题