I would like to change the branch of my Git repository but not touch the working directory. Essentially change the state of the git repository without changing the state of the working directory. No local files should be overwritten. The difference between the working directory and the state of the branch should become immediately apparent when running git status
.
I know that I could just copy out the files, change the branch, and copy them back in. I'm looking for a cleaner solution.
Example:
git init
echo Hello > myfile
git add myfile
git commit -m initial
git checkout -b foo
echo "Good Bye" > myfile
git commit -a -m "first commit on branch foo"
echo "Now I'd like to have this file, unstaged, on branch master after I've already changed it" > myfile
git checkout master # error