Недавно код проекта компании был перенесен в Gitlab.После переноса выяснилось, что файл фильтра недействителен.На этот раз я запишу методы добавления и проверки.
add.gitignore
Github может загружать файлы .gitignore, соответствующие различным голосам, адрес доступа: https://github.com/github/gitignore .
Улучшить .gitignore
После скачивания я модифицировал файл и выложил его напрямую.
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
.DS_Store
## User settings
xcuserdata/
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
*.xcscmblueprint
*.xccheckout
*.xcuserstate
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
build/
DerivedData/
*.moved-aside
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
## Obj-C/Swift specific
*.hmap
## App packaging
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
Pods/
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build/
# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode
iOSInjectionProject/
Отправьте файл .gitignore на склад.
Сочетание клавиш Mac для отображения скрытых файлов: команда + сдвиг +.
Терминал отображает команду скрытых файлов:
cd 文件名
ls -a
Нет проблем проверить .gitignore (сам не проверял. Кто знал, что когда я изменил имя файла, оно изменилось на формат типа .gitignore.gitignore) и отправить его.
git add .gitignore
git commit -m "添加项目忽略文件"
git push
.gitignore вступает в силу
Каждый должен знать правила git. .gitignore может игнорировать только файлы, которые не отслеживались. Если некоторые файлы были включены в управление версиями, изменение .gitignore недействительно.
Решение: мы можем сначала удалить путь к кэшу, использовать add., чтобы добавить и повторно отправить
git rm -r --cached .
git add .
git commit -m "update .gitignore"
git push