title: How to create a new branch and move existing code there
body: <p>Let say that I start to work on clear <code>master</code> branch - <code>no changes to commit</code>.
  Do some local changes but realize that this modifications should be in a separate <code>branch</code> instead of <code>master</code>. </p>
  
  <p>Is there a way how to <strong>move</strong> this changes to separate new <code>branch</code> and restate <code>master</code> branch into status <code>no changes to commit</code> ?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Following the accepted answer for <a href="https://stackoverflow.com/questions/6764893/git-branching-how-to-make-current-master-a-branch-and-then-revert-master-back">git branching - how to make current master a branch and then revert master back to previous version? </a>...When following the steps, my master will still have modified files.See the <strong>last comment 7</strong>.</p>
  
  <p>Do I am missing something ?</p>
  
  <pre><code>$ 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 &lt;file&gt;..." to update what will be committed)
  #   (use "git checkout -- &lt;file&gt;..." 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 &lt;file&gt;..." to update what will be committed)
  #   (use "git checkout -- &lt;file&gt;..." 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 &lt;file&gt;..." to update what will be committed)
  #   (use "git checkout -- &lt;file&gt;..." to discard changes in working directory)
  #
  #   modified:   test.txt                #7. in master test.txt is still modified !!!
  </code></pre>