I really like git. At least, I like the idea of git. Being able to checkout my master project as a separate branch where I can change whatever I want without risk of screwing everything else up is awesome. But it's not working.
Basically, my workflow is like this:
Every time I checkout a branch to another branch, make changes to the one branch, and then checkout the original branch, I still have all the files and changes that happened in the other branch. This is getting extremely frustrating. I've read that this can happen when you have files open in the IDE while doing this, but I've been pretty careful about that and both closed the files in the IDE, closed the IDE, and shut down my rails server before switching branches, and this still happens. Also, running 'git clean -f' either deletes everything that happened after some arbitrary commit (and randomly, at that), or, as in the latest case, didn't change anything back to its original state.
I thought I was using git correctly, but at this point, I'm at my wit's end here. I'm trying to work with a bunch of experimental code using a stable version of my project, but I keep having to manually track down and fix all the changes I made. Any ideas or suggestions?
git checkout -b photo_tagging
git branch # to make sure it's right
# make a bunch of changes, creations, etc
git status # see what's changed since before
git add . # approve of the changes, I guess, since if I do git commit after this, it says no changes
git commit -m 'these are changes I made'
git checkout master
git branch #=> *master
# look at files, tags_controller is still there, added in photo_tagging
# and code added in photo_tagging branch are still there in *master
This seems to happen whether I do a commit or not on the branch.
I had this issue when I tried to switch temp to another branch from the master branch and when I would change something on that temp page and without committing the changes I would checkout the master branch again, it actually merged all the changes from the TEMP branch into MASTER.
ANSWER:
Whenever you checkout to a TEMP branch, COMMIT your changes. That way if you commit them on the TEMP branch and checkout MASTER again, it will work as supposed.