2015-07-16 6 views
6

Ich habe durch andere Fragen zu ähnlichen Frage durchgesehen.Wie Sie alle Remote-Branch abrufen, "Git fetch --all" funktioniert nicht

Aber sie scheinen zu sagen, die Antwort ist git fetch --all.

Aber in meinem Fall, es funktioniert nicht.

Dies ist, was ich dafür getan habe.

> git branch 
* master 

> git branch -r 
origin/master 
origin/A 

> git fetch --all 
> git branch 
* master  #still not updated 

> git fetch origin/A 
fatal: 'origin/A' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

> git fetch remotes/origin/A 
fatal: 'origin/A' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

Und ich habe auch versucht, git pull --all auch, aber das Ergebnis ist das gleiche.

------------------- ------------------- bearbeiten

> git pull --all 
Already up-to-date. 

> git branch 
* master    # I think it should show branch A also 

> git remote show origin 
HEAD branch: master 
Remote branches: 
    A  tracked 
    master tracked 

------------------- ------------------- bearbeiten

> git pull origin A 
* branch   A  -> FETCH_HEAD 
Already up-to-date. 

> git branch 
* master     # I think it should show barnch A also 
+2

1. Es ist 'git fetch Herkunft A' nicht' git find Herkunft/A'. 2. 'git pull' führt einen' fetch' und einen 'merge' durch. 'git pull --all 'sollte alle ** tracked ** Zweige ziehen. – noahnu

+0

Von Ihrem Schnitt sieht es so aus, als würde es funktionieren. Was ist das Problem? – noahnu

+0

@noahnu Ich denke, 'git branch' sollte' branch A' sowie 'master' zeigen. – SangminKim

Antwort

6

git branch zeigt nur lokale Zweige an. git branch -r wird Remote-Niederlassungen anzeigen, wie Sie selbst gesehen haben.

git branch 
*master 

git branch -r 
origin/master 
origin/A 

git fetch --all aktualisiert die Liste, die Sie sehen, wenn Sie git branch -r geben, aber es wird die entsprechende lokale Zweige nicht erstellen.

Was Sie tun möchten, ist das Auschecken der Filialen. Dadurch wird eine lokale Kopie der Remote-Zweigstelle erstellt und der Upstream wird auf die Remote festgelegt.

git checkout -b mylocal origin/A 

git branch 
master 
*mylocal 

git branch -r 
origin/master 
origin/A 

mylocal in diesem Fall ist origin/A. Der Parameter -b wechselt nach der Erstellung zum neuen Zweig. Sie könnten auch einfach Folgendes eingeben: git checkout A wird den neuen Zweig automatisch benennen.

0

Sie müssen den abgerufenen Zweig auch lokal erstellen:

git fetch --all && git checkout A 
1

Ich denke, was Sie wirklich suchen, ist der git branch -a Befehl. Es zeigt alle lokalen und entfernten Zweige an. Hier ein Beispiel:

# Only show local branches 
$ git branch 
* master 
    develop 

# Only show remote branches 
$ git branch -r 
    origin/HEAD -> origin/master 
    origin/master 
    origin/develop 
    origin/foo 

# Show both local and remote branches 
$ git branch -a 
* master 
    develop 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 
    remotes/origin/develop 
    remotes/origin/foo 

Sie werden feststellen, dass alle Zweige vorhanden sind - der Befehl zeigt sowohl lokale als auch Remote-Zweige.

Der foo Zweig wird nur auf der Fernbedienung beendet, ich habe keinen lokalen foo Zweig. Um einen lokalen foo Zweig zu erstellen, würde ich den checkout Befehl verwenden:

# Create a local 'foo' branch from the remote one 
$ git checkout foo 
Branch foo set up to track remote branch foo from origin. 
Switched to a new branch 'foo' 

# Show both local and remote branches 
$ git branch -a 
* foo 
    master 
    develop 
    remotes/origin/HEAD -> origin/master 
    remotes/origin/master 
    remotes/origin/develop 
    remotes/origin/foo 

Dies sollte erklären, was Sie sehen vor Ort.

Verwandte Themen