Paso 3. Mantén tu fork actualizado


Estás contribuyendo a un proyecto de código abierto y notaste que tu fork no está sincronizado con el repositorio original. ¿Cómo puedes corregir eso?

Susana puede actualizar sus apuntes y el resto de personas puede descargarse los apuntes actualizados siempre que deseen.

Sincronizando un fork (por GitHub) 1

Desde la interfaz gráfica

Tan simple como hacer click en Fetch upstream:


Desde la terminal 2

¿Sabías que tu fork es huérfano? Si listas el repositorio remoto configurado, solo verás tu fork como origen:

git remote -v

output:

origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
origin  https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)

Necesitamos configurar esta información para restaurar la relación familiar con el repositorio original al que le hicimos un fork:

  1. Agregar un nuevo repositorio remoto conectado al proyecto del propietario



    Procesos que intervienen al sincronizar un fork
    git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
    
  2. ¡Salvaste a la familia! Ahora puedes ver el repositorio original y tu fork:

    git remote -v
    

    output:

    origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
    origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
    upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
    upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
    
  3. Sincronizada tu fork.

    1. Asegúrate que estás en la rama master de tu proyecto.

      git checkout master
      
    2. Ahora, puedes traer los cambios del repositorio original a tu fork.

      git fetch upstream
      

      output:

      remote: Enumerating objects: 16, done.
      remote: Counting objects: 100% (16/16), done.
      remote: Compressing objects: 100% (7/7), done.
      remote: Total 7 (delta 5), reused 0 (delta 0), pack-reused 0
      Unpacking objects: 100% (7/7), 1.72 Kio | 160.00 Kio/s, done.
      From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
         909ef5a..0b228a8  master     -> upstream/master
      

¡Hurra! 🥳 Tu fork está sincronizado