I created a new local repo with 1 file in it.
+ foo
|- .git
|- foo.txt (4 bytes)
I now modify foo.txt
and stage my change. Afterwards I execute git checkout -b new-branch
. Shouldn't my new branch have the state and files of the upstream-branch before my temporary changes?
Here is an example:
#-------setup git repo with 1 file and foo.txt (4 bytes)-------
$ git init .
Initialized empty Git repository in foo/.git/
$ echo 1234 > foo.txt
$ git add .
$ git commit -m 'first message'
[master (root-commit) 4aa4409] first message
1 file changed, 1 insertion(+)
create mode 100644 foo.txt
#-------modify foo.txt, stage and create new branch-------
$ echo 123456789 > foo.txt
$ git stage foo.txt
$ git checkout -b new-branch
Switched to a new branch 'new-branch'
$ cat foo.txt
123456789 #<---- I expected 1234 here