Suspend the work on a git branch and work on another (mainly locally)


Staff member
I have to work on different little features and I usually save them locally with
git stash save "feature name"

I read that <a href="" rel="nofollow">using branches has more sense</a>, and I believe it could be true, cause a branch allows you to keep also untracked files (while with <em>stash</em> I have to remember to add the <em>-u</em> parameter to keep them). And you also have the option to <em>git push</em> it on the remote repository.

So, from an initial clean <em>master</em> branch, I created a new <strong>local</strong> branch, with
git checkout -b feature_name
, and made some changes, created new files, etc.


<li>I would like to <strong>pause my incomplete work</strong> (so I would not commit anything, even if local, cause it has not sense to me) and have it available for keep <strong>working on it later</strong>.</li>
<li>Then I would like to <strong>switch back to a clean branch</strong> (master, where I was starting from) and <strong>create a new one</strong> for a second feature</li>

But if I
git checkout master
git checkout -b new_feature_2
I get all the the changes from the first feature branch merged into the branch I'm switching to.

Can someone explain me:

<li>Why that? Are not <strong>branches</strong> supposed to be something <strong>'divided' each from the others</strong> (so I can work on different things at the same time)? Or <strong>does that division exist JUST if I proceed with a commit in the branches?</strong></li>
<li>Is there a way to <strong>switch to a branch without merging</strong> the working directory? And, does it have sense, in the Git logic?</li>

Should I keep using <em>stashes</em> to do what I desire? (having different local working directories and switch between them, without committing to the repository).

My question is because <strong>I DON'T LIKE TO COMMIT!</strong> :)
Or, I mean, it has sense to me to <em>commit just the meaningful changes</em>.

I don't want the history to have commits with incomplete work, or not tested code, or anything that is not definitive.