Ten przykład może komuś pomóc:
Uwaga „ origin” to mój alias dla zdalnego „Co jest na Githubie„
Uwaga ” mybranch„ to mój alias dla mojej gałęzi „co jest lokalne”, który synchronizuję z github -
nazwa twojej gałęzi to „master”, jeśli nie została utworzona jeden. Jednak używam innej nazwy, mybranchaby pokazać, gdzie jest używany parametr nazwy gałęzi.
Czym dokładnie są moje zdalne repozytoria na Github?
$ git remote -v
origin https://github.com/flipmcf/Playground.git (fetch)
origin https://github.com/flipmcf/Playground.git (push)
Dodaj „inne repozytorium github tego samego kodu” - nazywamy to widelcem:
$ 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)
upewnij się, że nasze lokalne repozytorium jest aktualne:
$ git fetch
Zmień niektóre rzeczy lokalnie. powiedzmy plik ./foo/bar.py
$ git status
# On branch mybranch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: foo/bar.py
Przejrzyj moje niezatwierdzone zmiany
$ 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.
Zatwierdź lokalnie.
$ git commit foo/bar.py -m"I changed stuff"
[myfork 9f31ff7] I changed stuff
1 files changed, 2 insertions(+), 1 deletions(-)
Teraz jestem inny niż mój pilot (na github)
$ git status
# On branch mybranch
# Your branch is ahead of 'origin/mybranch' by 1 commit.
#
nothing to commit (working directory clean)
Porównaj to z pilotem - twoim widelcem: (często się to robi z 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.
(naciśnij przycisk git, aby zastosować je do pilota)
Czym różni się moja zdalna gałąź od zdalnej gałęzi głównej?
$ git diff origin/mybranch origin/master
Czym moje lokalne rzeczy różnią się od zdalnej gałęzi głównej?
$ git diff origin/master
Czym moje rzeczy różnią się od forka innej osoby, głównej gałęzi tego samego repozytorium?
$git diff mybranch someOtherRepo/master