In some places you wrote that you had untracked changes, and in some that you had unstaged changes. These are two different things and should be handled differently. If you have tracked, but unstaged changes, you should git stash your changes before checking out the new branch, and git stash pop them after merging A into the new branch.
For untracked changes, another way to ensure that they are also stashed and then just apply them to the new branch is to use git stash with the flag -u, which also stashes untracked changes. The flow in that case would be:
git branch newBranch master git stash -u git checkout newBranch git merge A git stash pop git add && git commit
I believe the state you are trying to arrive at is the following:
master branch remains unchanged - feature branch
A remains unchanged - There is a new branch
B branching off of master, which contains both the committed and untracked changes from branch A
First, note: When you use git checkout to checkout a different branch or commit, or when you execute commands that manipulate other branches, whatever was committed on the branch / commit you previously had checked out is not lost, and you can go back to it at any time using git checkout again. Additionally, untracked files will not be modified unless they are tracked in the commit / branch you are checking out.
Now, I would use the following commands:
git branch newBranch master to create a new branch off of master branch. git checkout newBranch to checkout the newly created branch. Remember that untracked files wont be modified unless they are tracked on the new branch, which from your description I understand they are not. Also remember that whatever was committed on branch A will stay there and will not be lost by switching to another branch. git merge A to merge the committed changes from branch A to the new branch. git add and git commit to add the untracked changes and commit them to the new branch.
Finally, you can either keep working on the new branch or if you want to go back to branch A, you can execute git checkout A to go back. Note that since the changes which were untracked on branch A are now tracked on branch B, if you change them again and checkout B you will get the version before the new changes from A.
git stashto stash your changes and keep them in your memory, change your branch tomaster, create another branch from there, push that branch and dogit stash popto get your stashed changes back.git stash, does it stash committed changes too?