Sinopsis
git notes add [-m <msg>] [<commit>]
git notes show [<commit>]
git notes append [-m <msg>] [<commit>]
git notes remove [<commit>]
Descripción
El comando git notes añade metadatos arbitrarios a commits sin reescribir el historial. Las notas se almacenan en una ref separada (refs/notes/commits) y se muestran junto al commit en git log.
Usos típicos: anotar resultados de CI, etiquetar cherry-picks, registrar metadatos de revisión. Las notas no se pushean por defecto: requieren refspecs específicos para sincronizarse con remotos.
En el uso diario, este comando se integra estrechamente con alias de shell, plugins de editor e integración continua. Los usuarios avanzados a menudo añaden alias que combinan los flags que siempre pasan. El formato de salida puede personalizarse vía configuración de Git. Cuando algo sale mal, ejecuta el comando con GIT_TRACE=1 para revelar las llamadas plumbing subyacentes.
Entender cómo este comando interactúa con el resto del modelo de datos de Git rinde dividendos. Cada comando opera sobre algún subconjunto de las piezas (objetos, index, refs, árbol de trabajo), y saber cuáles toca ayuda a predecir resultados y a recuperarse de errores.
Opciones comunes
| Subcomando | Descripción |
|---|---|
add | Attach a new note to a commit. |
append | Add to an existing note. |
edit | Open an editor on the note. |
show | Print the note. |
remove | Delete the note. |
list | List commits that have notes. |
--ref <ref> | Use a different notes namespace. |
Ejemplos
git notes add -m "Reviewed by Alice" abc123
# Attach a review note
git log --show-notes
# Show notes inline with log
git notes --ref=ci add -m "Build #42 passed" HEAD
# Use a custom namespace
git push origin 'refs/notes/*'
# Publish notes to the remote
Errores comunes
Forgetting to push and fetch the notes ref makes notes invisible to collaborators. Configure notes.displayRef = refs/notes/* so all namespaces show in git log. Notes don't survive history rewrites unless explicitly migrated.
Comandos relacionados
git log, git commit, git push, git fetch