Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>No need to stash.</p> <pre><code>git checkout -b new_branch_name </code></pre> <p>does not touch your local changes. It just creates the branch from the current HEAD and sets the HEAD there. So I guess that's what you want.</p> <p><strong>--- Edit to explain the result of checkout master ---</strong></p> <p>Are you confused because <code>checkout master</code> does not discard your changes?</p> <p>Since the changes are only local, git does not want you to lose them too easily. Upon changing branch, git does not overwrite your local changes. The result of your <code>checkout master</code> is:</p> <pre><code>M testing </code></pre> <p>, which means that your working files are not clean. git did change the HEAD, but did not overwrite your local files. That is why your last status still show your local changes, although you are on <code>master</code>.</p> <p>If you really want to discard the local changes, you have to force the checkout with <code>-f</code>.</p> <pre><code>git checkout master -f </code></pre> <p>Since your changes were never committed, you'd lose them.</p> <p>Try to get back to your branch, commit your changes, then checkout the master again.</p> <pre><code>git checkout new_branch git commit -a -m"edited" git checkout master git status </code></pre> <p>You should get a <code>M</code> message after the first checkout, but then not anymore after the <code>checkout master</code>, and <code>git status</code> should show no modified files.</p> <p><strong>--- Edit to clear up confusion about working directory (local files)---</strong></p> <p>In answer to your first comment, local changes are just... well, local. Git does not save them automatically, you must tell it to save them for later. If you make changes and do not explicitly commit or stash them, git will not version them. If you change HEAD (<code>checkout master</code>), the local changes are not overwritten since unsaved.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload