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?

Answers


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

Need Your Help

Appending query string params dynamically

php query-string

I have a webpage which allows users to filter results. Once a filter is set it is appended to the URL eg: www.testsite.com?show=active. The results are broken into several pages (simple pagination)...

Application Caching on iPad will not cache website data or pages

html ipad .htaccess caching manifest

I am running a DHTML page and want to cache the HTML, PHP file and IMAGE files that are referenced.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.