Skip to content

Instantly share code, notes, and snippets.

@LuisPalacios
Last active September 28, 2024 07:12
Show Gist options
  • Save LuisPalacios/9821bd9c9ff8183cf772fbe11cec55fc to your computer and use it in GitHub Desktop.
Save LuisPalacios/9821bd9c9ff8183cf772fbe11cec55fc to your computer and use it in GitHub Desktop.
Archivo gitattributes - definición de atributos por la extensión
#
# Archivo gitattributes - definición de atributos por la extensión
#
# Ejemplo para desarrollo multiplataforma: Windows, Linux, MacOS
#
# Otras colecciones de archivos .gitattributes para los lenguajes de programación más populares: https://github.com/gitattributes/gitattributes
#
# El objetivo es poder trabajar en entornos mixtos de Windows, Linux y MacOS
# y permitir que Git gestione los finales de línea en los archivos, logrando un comportamiento
# consistente para todos los desarrolladores. Este archivo es una buena práctica para normalizar
# los finales de línea en tu repositorio y evitar problemas con los finales de línea en tus archivos.
# Nota: Cuando comiences a usar este archivo, la configuración `core.autocrlf` en .git/config se ignora.
#
#
# Fases para realizar una re-normalización de los finales de línea en tu repositorio
#
# 1. Fase 1, cómo agregar el archivo .gitattributes a tu proyecto
#
# 1.1 curl -LJs -o .gitattributes https://gist.githubusercontent.com/LuisPalacios/9821bd9c9ff8183cf772fbe11cec55fc/raw/.gitattributes
# 1.2 git commit -a -m 'agregando .gitattributes para unificar finales de línea'
# 1.3 git push
# 1.5 Pide al equipo que haga pull y pause el trabajo hasta que la fase 2 esté completada.
#
# 2. Fase 2, normalización, encontrar y convertir todos los archivos a LF (Unix) en tu repositorio.
# El comando find a continuación es un ejemplo, adáptalo a tus necesidades.
#
# 2.1 Pide al equipo que pause el trabajo en el repositorio mientras normalizas los finales de línea.
# 2.2 find -E . -iregex '.*\.(c|cpp|h|hpp|md|svg|csx|yml|yaml|gitattributes|gitignore|json)' -exec dos2unix {} \;
# 2.3 git commit -a -m 'Conversión a dos2unix'
# 2.4 git push
# 2.5 RECOMENDADO: Pide al equipo que vuelva a clonar el repositorio, o al menos que haga pull y reanude el trabajo.
#
#
###############################################################################
# atributo # Comportamiento al hacer checkin # Comportamiento al hacer checkout
###############################################################################
# text # Normalizado a LF # Convertir a finales de línea nativos
# [text] eol=crlf # Normalizado a LF # Convertir a CRLF
# [text] eol=lf # Normalizado a LF # Convertir a LF
# -text or binary # Sin conversión # Sin conversión
# text=auto # Similar a "text" si es archivo de texto según git, de lo contrario, similar a "binary"
# unspecified # Volver a la configuración de core.autocrlf del entorno local
###############################################################################
#
# Si la extensión no está presente a continuación en el archivo entonces
# maneja los finales de línea automáticamente para los archivos detectados como texto
# y deja intactos todos los archivos detectados como binarios.
* text=auto
# De aquí en adelante especificamos lo que ocurrirá.
# Estos archivos son texto y deben ser normalizados (Convertir crlf => lf)
*.gitattributes text eol=lf
.gitignore text eol=lf
# Docker
Dockerfile text eol=lf
# Habilitar resaltado de sintaxis para archivos con extensiones `.gitattributes`.
*.gitattributes linguist-language=gitattributes
*.gitattributes linguist-detectable=true
*.gitattributes linguist-documentation=false
# Visual studio
*.csproj text merge=union eol=crlf
*.sln text merge=union eol=crlf
*.SLN text merge=union eol=crlf
*.manifest text eol=crlf
*.vcxproj text eol=crlf
*.vcxproj.filters text eol=crlf
*.user text eol=crlf
*.natvis text eol=crlf
*.rsp text eol=crlf
*.vcproj text eol=crlf
*.user.props text eol=crlf
*.dsp text eol=crlf
*.dsw text eol=crlf
# Microsoft
*.docx binary diff=astextplain
*.DOCX binary diff=astextplain
*.pptx binary diff=astextplain
*.PPTX binary diff=astextplain
*.xls binary diff=astextplain
*.XLS binary diff=astextplain
# las rutas absolutas son aceptables, al igual que los comodines
# /**/postinst* text eol=lf
# las rutas que no comienzan con / se tratan en relación a la carpeta .gitattributes
# relative/path/*.txt text eol=lf
# Fuentes
*.c text diff=cpp eol=lf
*.cc text diff=cpp eol=lf
*.cxx text diff=cpp eol=lf
*.cpp text diff=cpp eol=lf
*.cpi text diff=cpp eol=lf
*.c++ text diff=cpp eol=lf
*.hpp text diff=cpp eol=lf
*.h text diff=cpp eol=lf
*.h++ text diff=cpp eol=lf
*.hh text diff=cpp eol=lf
*.cs text diff=csharp eol=lf
*.java text diff=java eol=lf
*.js text eol=lf
*.csx text eol=lf
*.m text eol=lf
*.mm text eol=lf
*.frag text eol=lf
*.vert text eol=lf
*.mkb text eol=lf
*.icf text eol=lf
# HTML
*.html text diff=html eol=lf
*.css text eol=lf
# Archivos DB
*.sql text eol=lf
# Archivos objeto
*.slo binary
*.lo binary
*.o binary
*.obj binary
# Encabezados preconfigurados
*.gch binary
*.pch binary
# Librerías dinámicas
*.so binary
*.dylib binary
*.dll binary
# Librerías estáticas
*.lai binary
*.la binary
*.a binary
*.lib binary
# Ejecutables
*.exe binary
*.out binary
*.app binary
# Documentos
*.md text diff=markdown eol=lf
*.mdx text diff=markdown eol=lf
*.tex text diff=tex eol=lf
*.adoc text eol=lf
*.textile text eol=lf
*.mustache text eol=lf
*.csv text eol=lf
*.tab text eol=lf
*.tsv text eol=lf
*.txt text eol=lf
# rc?
*.rc text eol=lf
# Gráficos
*.svg text eol=lf
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
*.eps binary
*.ttf binary
Makefile text eol=lf
*.pbxproj text eol=lf
*.storyboard text eol=lf
*.plist text eol=lf
# Scripts
*.bash text eol=lf
*.fish text eol=lf
*.ksh text eol=lf
*.sh text eol=lf
*.zsh text eol=lf
# Windows
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.BAT text eol=crlf
*.CMD text eol=crlf
*.PS1 text eol=crlf
# Configuración
*.conf text eol=lf
# Serialización
*.json text eol=lf
*.toml text eol=lf
*.xml text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
development.settings.json.example text eol=lf
# Archivos comprimidos
*.7z binary
*.bz binary
*.bz2 binary
*.bzip2 binary
*.gz binary
*.lz binary
*.lzma binary
*.rar binary
*.tar binary
*.taz binary
*.tbz binary
*.tbz2 binary
*.tgz binary
*.tlz binary
*.txz binary
*.xz binary
*.Z binary
*.zip binary
*.zst binary
*.bin binary
*.jar binary
# Preservar EOL
*.patch -text
# Go
# ============
*.go text diff=golang eol=lf
# Python
# ============
*.pxd text diff=python eol=lf
*.py text diff=python eol=lf
*.py3 text diff=python eol=lf
*.pyw text diff=python eol=lf
*.pyx text diff=python eol=lf
*.pyz text diff=python eol=lf
*.pyi text diff=python eol=lf
# Binarios
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary export-ignore
*.pyo binary export-ignore
*.pyd binary
# Jupyter notebook
*.ipynb text eol=lf
# Formatos comunes de documentos
*.bibtex text diff=bibtex
*.doc binary
*.DOC binary
*.docx binary
*.DOCX binary
*.dot binary
*.DOT binary
*.pdf binary
*.PDF binary
*.rtf binary
*.RTF binary
*.epub binary
# Certificados
.der binary
.crt text eol=lf
.csr text eol=lf
.key text eol=lf
.pem text eol=lf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment