如何忽略 Git 存储库中的特定文件?
How can I ignore specific files from a Git repository?
当我使用 git 控制我的团队项目时,此文件总是更改:
MyProject.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
如何忽略此文件?
将它或包含该文件的文件夹添加到.gitignore。
当忽略带有 git 的文件时,您使用存储库根目录中的 .gitignore
文件。
这是我在工作和个人的所有 iOS 开发项目中使用的示例:
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
*.hmap
*.ipa
.idea/
# Pods - for those of you who use CocoaPods
Pods
xcuserdata/*
请注意,仅将其添加到 gitignore 将无济于事。您还需要从跟踪中删除文件。
您可以通过以下方式执行此操作:git rm --cached xcuserdata/*
这将使它不再被跟踪,但将其保留在文件系统中。
有关 gitignore 及其工作原理的更多信息,我建议阅读 http://git-scm.com/docs/gitignore
上的 scm 文档
- 将文件添加到 .gitignore 文件后,要忽略这些文件,我们必须执行一些命令。
要忽略我们在 .gitignore 文件中提到的文件,我们必须执行以下命令。
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
请参考this question一次
当我使用 git 控制我的团队项目时,此文件总是更改:
MyProject.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
如何忽略此文件?
将它或包含该文件的文件夹添加到.gitignore。
当忽略带有 git 的文件时,您使用存储库根目录中的 .gitignore
文件。
这是我在工作和个人的所有 iOS 开发项目中使用的示例:
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
DerivedData
*.hmap
*.ipa
.idea/
# Pods - for those of you who use CocoaPods
Pods
xcuserdata/*
请注意,仅将其添加到 gitignore 将无济于事。您还需要从跟踪中删除文件。
您可以通过以下方式执行此操作:git rm --cached xcuserdata/*
这将使它不再被跟踪,但将其保留在文件系统中。
有关 gitignore 及其工作原理的更多信息,我建议阅读 http://git-scm.com/docs/gitignore
上的 scm 文档- 将文件添加到 .gitignore 文件后,要忽略这些文件,我们必须执行一些命令。
要忽略我们在 .gitignore 文件中提到的文件,我们必须执行以下命令。
git rm -r --cached . git add . git commit -m ".gitignore is now working"
请参考this question一次