Logo hdtoledo
hdtoledo.dev
Módulos_del_Sistema
EJERCICIO_PRÁCTICO

Viajando en el Tiempo: Historial

Viajando en el Tiempo: Leyendo el Historial

Ahora que tienes tu primer commit, veamos cómo consultar el historial.

1. Ver el historial (Log)

bash
git log

Esto te muestra cada commit con su ID único (hash), el autor, la fecha y el mensaje. Para una vista más compacta:

bash
git log --oneline

2. Ver Diferencias (Diff)

Si modificaste un archivo pero aún no le haces git add, puedes ver exactamente qué líneas cambiaste:

bash
git diff

3. Deshacer Cambios

Si cambiaste un archivo en tu working directory y te arrepentiste (quieres volver al último commit):

bash
git restore archivo.txt

Ejercicio Práctico

  1. Modifica el archivo index.html que creaste antes.
  2. Ejecuta git diff para ver las líneas que cambiaste.
  3. Ejecuta git restore index.html y verifica que tus cambios desaparecieron y el archivo volvió a la normalidad.
  4. Vuelve a hacer un cambio, haz un git add . y git commit -m "Segundo cambio".
  5. Ejecuta git log --oneline y observa tus dos commits.