Jak wyświetlić listę zdalnych gałęzi w Git 1.7+?
Próbowałem git branch -r
, ale to tylko lista zdalnych gałęzi, które śledziłem lokalnie. Jak znaleźć listę tych, których nie mam? (Nie ma dla mnie znaczenia, czy polecenie wyświetla wszystkie zdalne gałęzie, czy tylko te, które nie są śledzone.)
15 answers
Dla zdecydowanej większości[1] z odwiedzających tutaj, poprawna i najprostsza odpowiedź na pytanie "Jak wymienić wszystkie zdalne gałęzie w Git 1.7+?"is:
git branch -r
Dla małej mniejszości[1]git branch -r
nie działa. Jeśli git branch -r
nie działa spróbuj:
git ls-remote --heads <remote-name>
Jeśli git branch -r
nie działa, to może, jak Cascabel mówi " zmodyfikowałeś domyślne refspec, aby git fetch
i git remote update
nie pobierały wszystkich remote
's gałęzie " .
[1] od pisania tego przypisu 2018-Luty, spojrzałem na komentarze i widzę, że git branch -r
działa dla zdecydowanej większości (około 90% lub 125 z 140).
Jeśli git branch -r
nie działa, sprawdź git config --get remote.origin.fetch
zawiera symbol wieloznaczny (*
) zgodnie z ta odpowiedź
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-06-22 11:40:20
remote show
pokazuje wszystkie gałęzie na pilocie, w tym te, które nie są śledzone lokalnie, a nawet te, które nie zostały jeszcze pobrane.
git remote show <remote-name>
Próbuje również pokazać status gałęzi względem lokalnego repo:
> git remote show origin
* remote origin
Fetch URL: C:/git/.\remote_repo.git
Push URL: C:/git/.\remote_repo.git
HEAD branch: master
Remote branches:
branch_that_is_not_even_fetched new (next fetch will store in remotes/origin)
branch_that_is_not_tracked tracked
branch_that_is_tracked tracked
master tracked
Local branches configured for 'git pull':
branch_that_is_tracked merges with remote branch_that_is_tracked
master merges with remote master
Local refs configured for 'git push':
branch_that_is_tracked pushes to branch_that_is_tracked (fast-forwardable)
master pushes to master (up to date)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-22 09:26:01
git branch -a | grep remotes/*
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-08-12 20:48:25
Using git branch -r
lists all remote branches and git branch -a
lists all branches on local and remote. Te listy stają się jednak przestarzałe. Aby te listy były aktualne, Uruchom
git remote update --prune
Który zaktualizuje listę lokalnych gałęzi o wszystkie nowe z pilota i usunie wszystkie, których już nie ma. Uruchomienie polecenia update bez --prune spowoduje pobranie nowych gałęzi, ale nie usunie tych, które nie są już na zdalnym serwerze.
Możesz przyspieszyć tę aktualizację, podając pilota, w przeciwnym razie będzie pobierać aktualizacje ze wszystkich pilotów, które dodałeś, w ten sposób
git remote update --prune origin
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-16 14:00:50
Ale
git branch -ar
Powinien to zrobić.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-03-24 11:25:27
Możesz również wykonać git fetch
, po którym następuje git branch -r
. Bez fetch nie zobaczysz najbardziej aktualnych gałęzi.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-04 09:22:30
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-07-04 21:08:10
Najprostszy sposób jaki znalazłem:
git branch -a
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-08-04 14:42:35
Najlepszym poleceniem do uruchomienia jest git remote show [remote]
. Spowoduje to wyświetlenie wszystkich oddziałów, zdalnych i lokalnych, śledzonych i nie śledzonych.
Oto przykład z projektu open source:
> git remote show origin
* remote origin
Fetch URL: https://github.com/OneBusAway/onebusaway-android
Push URL: https://github.com/OneBusAway/onebusaway-android
HEAD branch: master
Remote branches:
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
refs/remotes/origin/branding stale (use 'git remote prune' to remove)
Local branches configured for 'git pull':
develop merges with remote develop
master merges with remote master
Local refs configured for 'git push':
develop pushes to develop (local out of date)
master pushes to master (up to date)
Jeśli chcemy tylko uzyskać zdalne gałęzie, możemy użyć grep
. Komenda, której chcemy użyć to:
grep "\w*\s*(new|tracked)" -E
Z tą komendą:
> git remote show origin | grep "\w*\s*(new|tracked)" -E
amazon-rc2 new (next fetch will store in remotes/origin)
amazon-rc3 new (next fetch will store in remotes/origin)
arrivalStyleBDefault new (next fetch will store in remotes/origin)
develop tracked
master tracked
Możesz również utworzyć alias:
git config --global alias.branches "!git remote show origin | grep \w*\s*(new|tracked) -E"
Wtedy możesz po prostu uruchomić git branches
.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-06 14:33:42
TL; TR;
Oto rozwiązanie twojego problemu:
git remote update --prune # To update all remotes
git branch -r # To display remote branches
Lub:
git remote update --prune # To update all remotes
git branch <TAB> # To display all branches
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-10-28 16:42:11
Z GitBash możesz użyć:
Git branch-a
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-12-12 13:13:01
Skończyłem robiąc mess Shell pipeline, aby uzyskać to, czego chciałem, po prostu połączyłem gałęzie z origin remote:
git branch -r --all --merged \
| tail -n +2 \
| grep -P '^ remotes/origin/(?!HEAD)' \
| perl -p -e 's/^ remotes\/origin\///g;s/master\n//g'
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-07-31 18:49:31
Używając tego polecenia,
git log -r --oneline --no-merges --simplify-by-decoration --pretty=format:"%n %Cred CommitID %Creset: %h %n %Cred Remote Branch %Creset :%d %n %Cred Commit Message %Creset: %s %n"
CommitID : 27385d919
Remote Branch : (origin/ALPHA)
Commit Message : New branch created
Wyświetla listę wszystkich zdalnych gałęzi, w tym wiadomości zatwierdzeń, Id zatwierdzeń, które są odsyłane przez zdalne gałęzie.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-03-01 12:53:19
Upewnij się, że zdalne pochodzenie, które wymieniasz, jest repozytorium, które chcesz, a nie starszym klonem.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-06-13 09:28:17
Try
git branch -at
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-08-12 20:41:14