I have to work on different little features and I usually save them locally with
.
I read that <a href="http://codingkilledthecat.wordpress.com/2012/04/27/git-stash-pop-considered-harmful/" 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
, and made some changes, created new files, etc.
<h3>Now...</h3>
<ol>
<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>
</ol>
But if I
or
I get all the the changes from the first feature branch merged into the branch I'm switching to.
Can someone explain me:
<ul>
<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>
</ul>
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.
Code:
git stash save "feature name"
I read that <a href="http://codingkilledthecat.wordpress.com/2012/04/27/git-stash-pop-considered-harmful/" 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
Code:
git checkout -b feature_name
<h3>Now...</h3>
<ol>
<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>
</ol>
But if I
Code:
git checkout master
Code:
git checkout -b new_feature_2
Can someone explain me:
<ul>
<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>
</ul>
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.