J'ai poussé vers un référentiel Bitbucket distant et récemment un collègue a poussé une nouvelle branche qu'il a créée dans le même référentiel.
J'essaye de récupérer les modifications qu'il a téléchargées.
$ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master
$ git branch -r origine / maître
Dans l'interface utilisateur Web de Bitbucket, je peux voir la branche qu'il a créée. Comment puis-je faire ceci?
Prochain essai:
$ git fetch bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
Si la branche qu'il a créée s'appelle new_branch_b, dois-je m'attendre à voir ce qui suit?
$ git branch -r
origin/master
origin/new_branch_b
Troisième essai:
$ git remote update
Fetching bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
$ git branch -r
origin/master
Quatrième essai:
[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
J'ai appelé la télécommande bitbucket
plutôt que l'origine (du moins c'est ce dont je me souviens; je l'ai configurée il y a un moment)
Cinquième essai:
J'ai mis à jour la configuration à distance de Bitbucket selon la réponse de kan :
$ git config -e
[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*
Pour la plupart des gens, cela s'appellera origine:
[remote "origin"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
Ensuite,
$ git remote update
Fetching bitbucket
Password for 'https://user@bitbucket.org':
remote: Counting objects: 48, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 35 (delta 21), reused 0 (delta 0)
Unpacking objects: 100% (35/35), done.
From https://bitbucket.org/user/repo
* [new branch] branch_name1 -> origin/branch_name1
* [new branch] branch_name2 -> origin/branch_name2
.... etc.
Je pense que git fetch origin
cela fonctionnerait aussi pour git remote update
.
git fetch origin
fait le travail
refs/remotes/bitbucket/*
au lieu derefs/remotes/origin/*
.