Este ejemplo podría ayudar a alguien:
Nota "origin
" es mi alias de distancia "Lo que está en Github"
Nota "mybranch
" es mi alias para mi rama "lo local" que soy sincronizándose con github
--el nombre de su rama es 'maestro' si no creó uno. Sin embargo, estoy usando el nombre diferente mybranch
para mostrar dónde se usa el parámetro de nombre de rama.
¿Cuáles son exactamente mis repositorios remotos en github?
$ git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
Añadir el "otro repositorio GitHub del mismo código" - a esto lo llamamos un tenedor:
$ git remote add someOtherRepo https://github.com/otherUser/Playground.git
$git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
someOtherRepo https://github.com/otherUser/Playground.git (push)
someOtherRepo https://github.com/otherUser/Playground.git (fetch)
asegúrese de que nuestro repositorio local es hasta la fecha:
$ git fetch
Cambio algunas cosas localmente digamos file ./foo/bar.py
$ git status
# On branch mybranch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo/bar.py
Revisión mis cambios no confirmados
$ git diff mybranch
diff --git a/playground/foo/bar.py b/playground/foo/bar.py
index b4fb1be..516323b 100655
--- a/playground/foo/bar.py
+++ b/playground/foo/bar.py
@@ -1,27 +1,29 @@
- This line is wrong
+ This line is fixed now - yea!
+ And I added this line too.
Commit localmente.
$ git commit foo/bar.py -m"I changed stuff"
[myfork 9f31ff7] I changed stuff
1 files changed, 2 insertions(+), 1 deletions(-)
Ahora, yo soy diferente de mi control remoto (en github)
$ git status
# On branch mybranch
# Your branch is ahead of 'origin/mybranch' by 1 commit.
#
nothing to commit (working directory clean)
Dif esto con mando a distancia - el tenedor: (esto se hace con frecuencia con git diff master origin
)
$ git diff mybranch origin
diff --git a/playground/foo/bar.py b/playground/foo/bar.py
index 516323b..b4fb1be 100655
--- a/playground/foo/bar.py
+++ b/playground/foo/bar.py
@@ -1,27 +1,29 @@
- This line is wrong
+ This line is fixed now - yea!
+ And I added this line too.
(git push para aplicar estos a control remoto)
¿Cómo funciona mi remot ¿La rama difiere de la rama principal remota?
$ git diff origin/mybranch origin/master
¿En qué se diferencia mi material local de la rama maestra remota?
$ git diff origin/master
¿En qué se diferencia mi material de la horquilla de otra persona, rama principal del mismo repositorio?
$git diff mybranch someOtherRepo/master
posible duplicado de [comparar git branch local con sucursales remotas?] (Http://stackoverflow.com/questions/1800783/compare-local-git-branch-with-remote-branch) –