He estado empujando a un repositorio remoto de Bitbucket y recientemente un colega ha empujado una nueva sucursal que creó al mismo repositorio.
Estoy tratando de recuperar los cambios que cargó.
$ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master
$ git branch -r origin / master
En la interfaz de usuario web de Bitbucket puedo ver la rama que ha creado. ¿Cómo puedo hacer esto?
Siguiente intento:
$ git fetch bitbucket
Password for 'https://[email protected]':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
Si la rama que creó se llama new_branch_b, ¿ debería esperar ver lo siguiente?
$ git branch -r
origin/master
origin/new_branch_b
Tercer intento:
$ git remote update
Fetching bitbucket
Password for 'https://[email protected]':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
$ git branch -r
origin/master
Cuarto intento:
[remote "bitbucket"]
url = https://[email protected]/user/repo.git
Llamé al control remoto en bitbucketlugar de al origen (al menos eso es lo que recuerdo; lo configuré hace un tiempo)
Quinto intento:
Actualicé la configuración remota de Bitbucket según la respuesta de kan :
$ git config -e
[remote "bitbucket"]
url = https://[email protected]/user/repo.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*
Para la mayoría de las personas se llamará origen:
[remote "origin"]
url = https://[email protected]/user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
Después,
$ git remote update
Fetching bitbucket
Password for 'https://[email protected]':
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
.... y así.
Creo git fetch originque también funcionaría git remote update.

refs/remotes/bitbucket/*lugar derefs/remotes/origin/*.git fetch originhace el trabajoRespuestas:
La
remotesección también especifica las reglas de búsqueda. Podría agregar algo como esto para obtener todas las ramas del control remoto:(O reemplazar
originconbitbucket)Lea sobre esto aquí: 10.5 Git Internals - The Refspec
fuente
fetch = +refs/heads/master:refs/remotes/origin/masterpara mí. Reemplazarmasterpor*solucionó mi problema.git cloneun proyecto. No recuerdo haber hecho nada especial con mi git local.clonesido interrumpido y luego reanudado? ¿O algo más ha accedido al repositorio al mismo tiempo?Actualice su control remoto si aún no lo ha hecho:
fuente
git remote updatepuedo ver la nueva sucursal en la interfaz de usuario. Graciasgit branch -r. En git-scm.com/docs/git-branch dice "Opción -r hace que se enumeren las ramas de seguimiento remoto, y la opción -a muestra las ramas locales y remotas".git remote updaterecupera todas las ramas de todos los controles remotos enumerados engit remote -v.git checkout origin/mastery luego megit branch master; git checkout masterSi clona con el
--depthparámetro, se establece que.git/configno se buscarán todas las ramas, sino solo las maestras.Simplemente puede omitir el parámetro o actualizar el archivo de configuración desde
a
fuente
.git/config, para que las personas puedan encontrarlo.Tuve el mismo problema. Parece que la solución más fácil es simplemente quitar el control remoto, leerlo y buscarlo.
fuente
git remote -vle mostrará sus controles remotos para que pueda obtener la URL, lagit remote rm origineliminará y lagit remote add origin <url>volverá a agregar.warning: ignoring broken ref refs/remotes/origin/HEADPor desgracia,
git branch -aygit branch -rhacerlo sin muestra todas las ramas remotas, si no ha ejecutado un "git fetch".git remote show origintrabaja constantemente todo el tiempo. Tambiéngit show-refmuestra todas las referencias en el repositorio de Git. Sin embargo, funciona igual que elgit branchcomando.fuente