"No se pueden actualizar rutas y cambiar a rama al mismo tiempo"
A veces uso la opción checkout -b
para crear una nueva rama, comprobarla al mismo tiempo y configurar el seguimiento en un solo comando.
En un nuevo entorno, obtengo este error:
$ git checkout -b test --track origin/master
fatal: Cannot update paths and switch to branch 'test' at the same time.
Did you intend to checkout 'origin/master' which can not be resolved as commit?
¿Por qué no le gusta a Git? Esto solía funcionar con el mismo repositorio.
10 answers
'
origin/master
' que no se puede resolver como commit
Extraño: necesitas revisar tus controles remotos:
git remote -v
Y asegúrese de que origin
se obtiene:
git fetch origin
Entonces:
git branch -avv
(para ver si has obtenido una rama origin/master
)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-10 12:04:50
FWIW: Si tiene un error tipográfico en su nombre de rama obtendrá este mismo error.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-29 09:00:32
Puede obtener este error en el contexto de, por ejemplo, una compilación de Travis que, por defecto, comprueba el código con git clone --depth=50 --branch=master
. Hasta donde yo sé, puedes controlar --depth
a través de .travis.yml
pero no el --branch
. Dado que el control remoto solo rastrea una sola rama, debe actualizar el control remoto de forma independiente para rastrear las referencias del control remoto deseado.
Antes:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
La solución:
$ git remote set-branches --add origin branch-1
$ git remote set-branches --add origin branch-2
$ git fetch
Después de:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/branch-1
remotes/origin/branch-2
remotes/origin/master
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-05-14 14:40:46
¡Esta cosa simple funcionó para mí!
Si dice que no puede hacer 2 cosas al mismo tiempo, sepárelas.
git branch branch_name origin/branch_name
git checkout branch_name
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-03 10:59:22
Puedes seguir estos pasos cuando te topes con este problema:
- Ejecute el siguiente comando para listar las ramas conocidas para su repositorio local.
Git remote show origin
Que produce esto:
remote origin Fetch URL: <your_git_path> Push URL: <your_git_path> HEAD branch: development Remote branches: development tracked Feature2 tracked master tracked refs/remotes/origin/Feature1 stale (use 'git remote prune' to remove) Local branches configured for 'git pull': Feature2 merges with remote Feature2 development merges with remote development master merges with remote master Local refs configured for 'git push': Feature2 pushes to Feature2 (up to date) development pushes to development (up to date) master pushes to master (local out of date)
- Después de verificar los detalles como (fetch URL, etc.), ejecute este comando para obtener cualquier rama nueva (es decir, que desee verificar en su repositorio local) que exista en el remoto pero no en su local.
» git remote update Fetching origin From gitlab.domain.local:ProjectGroupName/ProjectName * [new branch] Feature3 -> Feature3
Como puede ver, la nueva rama se ha obtenido desde el control remoto.
3. Finalmente, comprueba la rama con este comando
» git checkout -b Feature3 origin/Feature3 Branch Feature3 set up to track remote branch Feature3 from origin. Switched to a new branch 'Feature3'
No es necesario decirle explícitamente a Git que rastree(usando track track) la rama con remote.
El comando anterior establecerá la rama local para rastrear la rama remota desde el origen.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-29 10:13:48
Para mí necesitaba agregar el control remoto:
git remote -add myRemoteName('origin' in your case) remoteGitURL
Entonces podría buscar
git fetch myRemoteName
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-07-02 17:15:44
Primero necesitas Fetch
el remoto (la rama específica), luego puedes crear un br local y rastrearlo con esa rama remota usando tu comando (es decir, checkout
con-b y track track).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-02 12:56:05
Debes ir al directorio de submódulos y ejecutar git status
.
Es posible que vea que se eliminaron muchos archivos. Usted puede ejecutar
git reset .
git checkout .
git fetch -p
-
git rm --cached submodules
//submoudles es tu nombre git submoudle add ....
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-24 05:52:45
Puede usar estos comandos: actualización remota de git, git fetch, git checkout-b branch_nameA origen: branch_nameB
Creo que tal vez es debido a su rama local no puede rastrear la rama remota
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-19 02:02:26
Provoca que tu rama local no rastree la rama remota. Como dijo ssasi, necesita usar estos comandos:
git remote update
git fetch
git checkout -b branch_nameA origin/branch_nameB
Acabo de resolver mi problema....
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-19 11:13:51