Contexto: estoy trabajando en el maestro agregando una característica simple. Después de unos minutos me di cuenta de que no era tan simple y que debería haber sido mejor trabajar en una nueva sucursal.Git: crea una bifurcación desde cambios no asignados/no confirmados en el maestro
Esto siempre me pasa y no tengo ni idea de cómo cambiar a otra rama y tomar todos estos cambios sin compromiso conmigo dejando la rama principal limpia. git stash && git stash branch new_branch
supone que simplemente lograr eso, pero esto es lo que me pasa:
~/test $ git status
# On branch master
nothing to commit (working directory clean)
~/test $ echo "hello!" > testing
~/test $ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: testing
#
no changes added to commit (use "git add" and/or "git commit -a")
~/test $ git stash
Saved working directory and index state WIP on master: 4402b8c testing
HEAD is now at 4402b8c testing
~/test $ git status
# On branch master
nothing to commit (working directory clean)
~/test $ git stash branch new_branch
Switched to a new branch 'new_branch'
# On branch new_branch
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: testing
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/[email protected]{0} (db1b9a3391a82d86c9fdd26dab095ba9b820e35b)
~/test $ git s
# On branch new_branch
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: testing
#
no changes added to commit (use "git add" and/or "git commit -a")
~/test $ git checkout master
M testing
Switched to branch 'master'
~/test $ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: testing
#
no changes added to commit (use "git add" and/or "git commit -a")
¿Conoce si hay alguna manera de lograr esto?
Aunque no existe una solución más sencilla a su problema, ¿podría especificar en lo que el resultado que se obtiene difiere de lo que quería? – Gauthier
haciendo lo anterior o las respuestas en la parte inferior, los cambios sin compromiso están tanto en el maestro como en la nueva rama. Los quiero solo en la nueva sucursal, así que puedo pagar master y trabajar en otra cosa sin tener estos cambios flotando alrededor de – knoopx
ver mi respuesta editada. Debe confirmar los cambios locales en la nueva sucursal si desea pagar un master limpio. Los cambios locales son solo las diferencias entre el HEAD actual y sus archivos en el disco. Estos cambios en los archivos locales no están versionados, debe indicarle a git que los guarde en algún lugar si desea recuperarlos más adelante. – Gauthier