Question

So, I have two git branches, master and testing. I checkout testing. I make some changes that are only halfway done and not ready to even stage let alone commit, I'm just screwing around. If I checkout master again, my screwy changes are included!! What??

So I could accidentally have some bad stuff in master just because it was not good enough to even commit in testing?

I thought branches would segregate my work. I tried staging even and that didn't seem to work. It seemed like I have to actually commit in testing or else my changes will stay visible (but uncommitted) in the files in my master branch.

What am I missing?

Was it helpful?

Solution

That's what git-stash is for. You can stash your changes using

git stash

and get them back using

git stash apply

when you are done you should clear your stash using

git stash clear

If you want to just delete your changes you can use

git reset --hard
git clean -fd

Info taken from here.

OTHER TIPS

You could simply make a "tmp" branch, and commit in it.

git checkout -b tmp

That way, master, and testing are unchanged.
And you can resume your changes in tmp at any time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top