remota - git pull
¿Cómo puedo cambiar a otra rama en git? (4)
¿Cuál de estas líneas es correcta?
git checkout ''another_branch''
O
git checkout origin ''another_branch''
O
git checkout origin/''another_branch''
¿Y cuál es la diferencia entre estas líneas?
Cambiando a otra rama en git. Respuesta directa,
git-checkout - Cambiar ramas o restaurar archivos de trabajo
git fetch origin <----this will fetch the branch
git checkout branch_name <--- Switching the branch
Antes de cambiar la rama, asegúrese de no tener ningún archivo modificado, en ese caso, puede confirmar los cambios o puede esconderlos.
Compruebe: git branch -a
Si está obteniendo sólo una rama. A continuación, siga los pasos a continuación.
- Paso 1:
git config --list - Paso 2:
git config --unset remote.origin.fetch - Paso 3:
git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/*
Si another_branch ya existe localmente y no está en esta rama, git checkout another_branch cambia a la rama.
Si another_branch no existe pero origin/another_branch , entonces git checkout another_branch es equivalente a git checkout -b another_branch origin/another_branch;git branch -u origin/another_branch . Eso es para crear another_branch desde origin/another_branch y establecer origin/another_branch como el another_branch ascendente de another_branch .
Si no existe ninguno, git checkout another_branch devuelve un error.
git checkout origin another_branch devuelve un error en la mayoría de los casos. Si el origin es una revisión y another_branch es un archivo, verifica el archivo de esa revisión, pero lo más probable es que no sea lo que usted espera. origin se utiliza principalmente en git fetch , git pull y git push como remoto, un alias de la url al repositorio remoto.
git checkout origin/another_branch tiene éxito si existe origin/another_branch . Lleva a estar en estado HEAD separado, no en ninguna rama. Si realiza nuevas confirmaciones, las nuevas confirmaciones no son accesibles desde ninguna de las sucursales existentes y ninguna de ellas se actualizará.
[ git checkout "branch_name" ]
es otra manera de decir:
[ git checkout -b branch_name origin/branch_name ]
en caso de que "branch_name" exista solo de forma remota.
[ git checkout -b branch_name origin/branch_name ] es útil en caso de que tenga varios controles remotos.
Con respecto a [ git checkout origin ''another_branch'' ] no estoy seguro de que esto sea posible, AFAK, puede hacerlo usando el comando "fetch" - [ git fetch origin ''another_branch'' ]