Git: który jest domyślnie skonfigurowany zdalny dla branch?
Mam zdalne repozytorium hub
. Pracuję tylko w gałęzi master
.
Ostatnie zdanie poniższego Komunikatu o błędzie sprawia, że zastanawiam się: jak mogę dowiedzieć się, który jest "default configured remote for your current branch" ? Jak to ustawić?
[myserver]~/progs $ git remote -v
hub ~/sitehub/progs.git/ (fetch)
hub ~/sitehub/progs.git/ (push)
[myserver]~/progs $ git branch -r
hub/master
[myserver]~/progs $ cat .git/HEAD
ref: refs/heads/master
[myserver]~/progs $ git pull hub
You asked to pull from the remote 'hub', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
3 answers
Śledź zdalną gałąź
Możesz określić domyślne zdalne repozytorium do pchania i ciągnięcia używając opcji track git-branch. Zwykle można to zrobić, podając opcję --track podczas tworzenia lokalnej gałęzi master, ale ponieważ już istnieje, zaktualizujemy konfigurację ręcznie w następujący sposób:
Edytuj swój .git/config
[branch "master"]
remote = origin
merge = refs/heads/master
Teraz możesz po prostu git push i git pull.
[Źródło ]
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-05 22:58:46
Możesz to zrobić prościej, gwarantując, że twoje .gitconfig
pozostanie w znaczącym stanie:
Używanie Git w wersji v1.8.0 i nowszej
git push -u hub master
podczas pchania lub:git branch -u hub/master
Lub
(spowoduje to ustawienie pilota dla aktualnie sprawdzonej gałęzi na hub/master
)git branch --set-upstream-to hub/master
Lub
(spowoduje to ustawienie pilota dla gałęzi o nazwie branch_name
na hub/master
)git branch branch_name --set-upstream-to hub/master
Jeśli używasz v1.7.x
lub wcześniej
Musisz użyć --set-upstream
:git branch --set-upstream master hub/master
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-01-26 15:48:44
Dla kompletności: poprzednie odpowiedzi mówią, jak ustawić gałąź upstream, ale nie jak ją zobaczyć.
Jest na to kilka sposobów:
git branch -vv
pokazuje te informacje dla wszystkich gałęzi. (sformatowane na niebiesko w większości terminali)
cat .git/config
to też pokazuje.
Dla odniesienia:
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-05-23 12:18:11