Agregue .gitignore y filtre archivos para que surtan efecto

Recientemente, el código del proyecto de la empresa se transfirió a Gitlab. Después de la transferencia, se descubrió que el archivo de filtro no era válido. Esta vez registraré el método de adición y validación.

agregar.gitignore

Github puede descargar archivos .gitignore correspondientes a varias voces, dirección de acceso: https://github.com/github/gitignore

Mejorar .gitignore

Después de la descarga, modifiqué el archivo y lo publiqué directamente.

# 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/

Envíe el archivo .gitignore al almacén

Tecla de acceso directo de Mac para mostrar archivos ocultos: comando+mayús+.

La terminal muestra el comando de archivos actualmente ocultos:

cd 文件名
ls -a

 No hay problema en verificar .gitignore (no lo verifiqué yo mismo. Quién iba a saber que cuando modifiqué el nombre del archivo, cambió a un formato como .gitignore.gitignore) y enviarlo.

git add .gitignore   
git commit -m "添加项目忽略文件" 
git push 

.gitignore entra en vigor

Todo el mundo debería conocer las reglas de git. .gitignore solo puede ignorar archivos que no han sido rastreados. Si algunos archivos se han incluido en la gestión de versiones, modificar .gitignore no es válido.

Solución: primero podemos eliminar la ruta del caché, usar add. para agregar y volver a enviar

git rm -r --cached .    
git add .   
git commit -m "update .gitignore"
git push  

Supongo que te gusta

Origin blog.csdn.net/PianZhideNanRen/article/details/120324563
Recomendado
Clasificación