Comment créer une nouvelle branche et déplacer le code existant n'

Disons que je commence à travailler sur clair master branche - no changes to commit.
Faire quelques changements locaux, mais se rendre compte que ces modifications doivent être dans un autre branch au lieu de master.

Est-il un moyen comment déplacer cela change à nouveau séparée branch et de reformuler master branche en état de no changes to commit ?

MODIFIER

À la suite de la accepté de répondre pour git ramification - comment faire de maître actuel d'une branche et ensuite revenir maître retour à la version précédente? ...en suivant les étapes, mon maître aura encore des fichiers modifiés.Voir la dernier commentaire 7.

Ne me manque quelque chose ?

$ git branch                                   # 1. starting on master                                     
# On branch master
  nothing to commit, working directory clean


# On branch master                             # 2.modifying a file 
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")



$ git stash                                    # 3. stashing changes
Saved working directory and index state WIP on master: 393bfad initial commit
HEAD is now at 393bfad initial commit
$ git status
# On branch master
nothing to commit, working directory clean


$ git checkout -b experiment                   # 4. creating new branch experiment 
Switched to a new branch 'experiment'


$ git stash pop                                # 5. pop staged changes in exper.
# On branch experiment
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test.txt
#
no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (16b6871d43f367edd03f59558eca4163cd1a2b2f)


$ git checkout master                           #6. going back to master
M   test.txt
Switched to branch 'master'
git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   test.txt                #7. in master test.txt is still modified !!!

OriginalL'auteur | 2013-10-13