I tried following commands on the shell
git init
echo "test1" > test1.txt
git add test1.txt
git commit -a -m "test1"
echo "test2" >> test1.txt
git branch test
git checkout test
text.txt
now contains:
test1
test2
After checkout to branch test
all local modifications from master
get merged.
Why?
I expected that git
refuses checkout to test
because of the local changes. I expected that git asks for a commit or stash
the local changes.
Edit: I used a bash script to execute this commands. I get following output:
r@r:/tmp/test$ ./createrepo
Initialized empty Git repository in /tmp/test/.git/
[master (root-commit) 0407f5b] test1
1 file changed, 1 insertion(+)
create mode 100644 test1.txt
M test1.txt
Switched to branch 'test'