¿Cómo dejas de rastrear una rama remota en Git?
¿Cómo dejar de rastrear una rama remota en Git?
Estoy pidiendo detener el seguimiento porque en mi caso concreto, quiero eliminar la rama local, pero no la remota. Eliminar la local y empujar la eliminación a remoto también eliminará la rama remota:
¿Puedo simplemente hacer git branch -d the_branch
, y no se propagará cuando más tarde git push
?
Sólo propagar si fuera a correr git push origin :the_branch
más tarde?
8 answers
Como se mencionó en Yoshua Wuyts' respuesta, utilizando git branch
:
git branch --unset-upstream
Otras opciones:
No tienes que eliminar tu rama local.
Simplemente elimine su rama de seguimiento remoto:
git branch -d -r origin/<remote branch name>
(This will not delete the branch on the remote repo!)
Ver " Tener dificultades para entender git-fetch "
No existe tal concepto de ramas de seguimiento locales, solo que seguimiento remoto de ramas.
Así queorigin/master
es una rama de seguimiento remoto paramaster
en el repoorigin
Como se menciona en La respuesta de Dobes Vandermeer , también debe restablecer la configuración asociada a la rama local:
git config --unset branch.<branch>.remote
git config --unset branch.<branch>.merge
Elimine la información de origen de
<branchname>
.
Si no se especifica ninguna rama, por defecto la rama actual.
(git 1.8+, Oct. 2012, commit b84869e by Carlos Martín Nieto (carlosmn
))
Eso hará que cualquier push/pull sea completamente inconsciente de origin/<remote 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
2017-07-06 22:02:18
Para eliminar el upstream de la rama actual haz:
$ git branch --unset-upstream
Esto está disponible para Git v.1.8.0 o posterior. (Fuentes: 1.7.9 ref, 1.8.0 ref)
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-09-21 19:36:07
Para eliminar la asociación entre la rama local y remota ejecute:
git config --unset branch.<local-branch-name>.remote
git config --unset branch.<local-branch-name>.merge
Opcionalmente borra la rama local después si no la necesitas:
git branch -d <branch>
Esto no eliminará 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
2014-02-26 22:25:08
La forma más sencilla es editar .git/config
Aquí hay un archivo de ejemplo
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = [email protected]:repo-name
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "test1"]
remote = origin
merge = refs/heads/test1
[branch "master"]
remote = origin
merge = refs/heads/master
Suprímase la línea merge = refs/heads/test1
en la sección test1
branch
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
2011-11-08 07:28:49
Puede eliminar la rama de seguimiento remoto usando
git branch -d -r origin/<remote branch name>
Como VonC menciona anteriormente. Sin embargo, si conservas tu copia local de la sucursal, git push
todavía intentará empujar esa rama (lo que podría darle un error de avance no rápido como lo hizo con ruffin). Esto se debe a que la configuración push.default
por defecto es matching
que significa:
Matching - empuje todas las ramas coincidentes. Todas las ramas que tienen el mismo nombre en ambos extremos se consideran coincidentes. Este es el predeterminado.
(véase http://git-scm.com/docs/git-config en push.default
)
Viendo que esto probablemente no es lo que querías cuando eliminaste la rama de seguimiento remoto, puedes establecer push.default
a upstream
(o tracking
si tienes git
Upstream - empuja la rama actual a su rama upstream.
Usando
git config push.default upstream
Y git dejará de intentar enviar ramas que has "dejado de rastrear"."
Nota: El una solución más simple sería simplemente cambiar el nombre de su sucursal local a otra cosa. Eso eliminaría también cierto potencial de confusión.
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-23 12:34:48
Aquí hay una línea para eliminar todas las ramas de seguimiento remoto que coincidan con un patrón:
git branch -rd $(git branch -a | grep '{pattern}' | cut -d'/' -f2-10 | xargs)
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-06-01 10:17:40
Esta no es una respuesta a la pregunta, pero no pude averiguar cómo obtener un formato de código decente en un comentario anterior... así que auto-down-reputation-be-damned aquí está mi comentario.
Tengo la receta presentada por @Dobes en una entrada elegante de shmancy [alias] en mi .gitconfig:
# to untrack a local branch when I can't remember 'git config --unset'
cbr = "!f(){ git symbolic-ref -q HEAD 2>/dev/null | sed -e 's|refs/heads/||'; }; f"
bruntrack = "!f(){ br=${1:-`git cbr`}; \
rm=`git config --get branch.$br.remote`; \
tr=`git config --get branch.$br.merge`; \
[ $rm:$tr = : ] && echo \"# untrack: not a tracking branch: $br\" && return 1; \
git config --unset branch.$br.remote; git config --unset branch.$br.merge; \
echo \"# untrack: branch $br no longer tracking $rm:$tr\"; return 0; }; f"
Entonces puedo ejecutar
$ git bruntrack branchname
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-09-23 03:20:02
La forma más fácil de hacer esto es eliminar la rama de forma remota y luego usar:
Git fetch pr prune (también conocido como git fetch-p)
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
2013-05-09 17:36:27