Git: ¿Cómo comprobar si un repositorio local está actualizado?


Me gustaría saber si mi repositorio local está actualizado (y si no, idealmente, me gustaría ver los cambios).

¿Cómo podría comprobar esto sin hacer git fetch o git pull ?

Author: Misha Moroshko, 2011-10-29

9 answers

Intenta git fetch --dry-run El manual (git help fetch) dice:

--dry-run
Show what would be done, without making any changes.
 53
Author: Philip Oakley,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-29 13:29:45

Puede usar git status -uno para comprobar si su rama local está actualizada con la de origen.

 7
Author: flowdee,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-03-24 15:01:50

No realmente, pero no veo cómo git fetch dolería, ya que no cambiará ninguna de sus ramas locales.

 5
Author: Niclas Kirschmeier,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-29 11:55:15
git remote show origin

Resultado:

HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date) <-------
 4
Author: jim smith,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-30 10:35:13

Esto es imposible. ¿Cómo puede saber si el repositorio está "actualizado" sin ir al repositorio remoto para ver qué significa "actualizado"?

 2
Author: Jörg W Mittag,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-10-29 11:54:55

Debe ejecutar git fetch antes de poder comparar su repositorio local con los archivos de su servidor remoto.

Este comando solo actualiza sus ramas de seguimiento remoto y no afectará a su worktree hasta que llame a git merge o git pull.

Para ver la diferencia entre su rama local y su rama de seguimiento remoto una vez que haya obtenido, puede usar git diff o git cherry como se explica aquí.

 2
Author: braitsch,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:24

Otra alternativa es ver el estado de la rama remota usando git show-branch remote/branch para usarlo como comparación, puede ver git show-branch *branch para ver la rama en todos los controles remotos, así como su repositorio! echa un vistazo a esta respuesta para más https://stackoverflow.com/a/3278427/2711378

 2
Author: Amanuel Nega,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:26:24

Tendrá que emitir dos comandos:

  1. git fetch origin
  2. estado de git
 2
Author: user3695833,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-27 18:01:33

Primero use git remote update, para actualizar sus referencias remotas. Entonces usted puede hacer una de varias cosas, tales como:

  1. git status -uno le dirá si la rama que está rastreando está por delante, por detrás o ha divergido. Si no dice nada, el local y el control remoto es lo mismo.
  2. git show-branch *master te mostrará las confirmaciones en todos los ramas cuyos nombres terminan en 'master' (por ejemplo, master y origin/master).

Si usas -v con git remote update (git remote-v update) puedes ver cuál las ramas se actualizaron, por lo que realmente no necesita más comandos.

 0
Author: Piyush Agarwal,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-13 06:13:12