Contexte: je travaille sur master en ajoutant une fonctionnalité simple. Après quelques minutes, je me rends compte que ce n'était pas si simple et qu'il aurait dû être préférable de travailler dans une nouvelle branche.
Cela m'arrive toujours et je n'ai aucune idée de comment passer à une autre branche et prendre toutes ces modifications non validées avec moi en laissant la branche principale propre. Je supposais git stash && git stash branch new_branch
simplement accomplir cela, mais voici ce que j'obtiens:
~/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/stash@{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")
Savez-vous s'il existe un moyen d'y parvenir?