Git create branch from current checked out master?

dvcs, git, git-branch, version-control

Solution

First of all moving to a different branch based in the current HEAD is performed like this:

git checkout -b newbranch

Commit all the changes (assuming no newly added files, otherwise `git add` them):

git commit -a

Go back to the master branch:

git checkout master

The previously uncommitted changes will all be on the newbranch branch, and master will still be at the state it was without those changes.

Problem

There is a git controlled folder on a server where the main branch is checked out and a whole pile of files have been modified and not committed. Is there a way for me to commit the changes to a separate branch so I can go back to a clean version? ie I want to effecitvely undo all this persons changes but store them in another chance so if that person wants their changes they can switch to that branch. (Yes I know this is not how git is designed to work but that is my situation!) Any ideas very much appreciated.

Original source

Related problems