Git branch not working the way I expected it to
In my project master branch I commit changes: git commit -a
create & switch to new branch: git checkout -b newbranch
try some stuff...
realize 'stuff' didn't work out the way I thought it might so switch back to master: git checkout master with intent of moving along from there... but realize some files added in newbranch are still in TextMate... so...
I type git status I still see all the stuff I thought I'd left in newbranch is listed under "Untracked files"
I try: git reset --hard to take me back to that last commit..but changes in newbranch still persist?!?
what am I missing?
What are you missing? Well, the files in questions are untracked and git wouldn't touch those with a ten-foot pole. ;)
In all honestly, if you weren't going to commit anything there was probably no reason to checkout a new branch.
You could have tried the new changes as normal. If you didn't like what you saw but wanted to use the new code later, you could have stashed it, like so:
git stash save "Some changes that didn't work out."
If you absolutely wanted it gone instead, all you had to do was:
git clean -d --dry-run
and then when sure:
git clean -df