I'm new to branching in git and I'm a bit confused by the behaviour on swithing branches. Following these steps:
git init
Initialized empty Git repository in /Users/mads/Desktop/testing/.git/
echo 'hello a' > a.txt
echo 'hello b' > b.txt
git add *.txt
git commit -m "Initial commit"
[master (root-commit) 1ab870f] Initial commit
2 files changed, 2 insertions(+), 0 deletions(-)
create mode 100644 a.txt
create mode 100644 b.txt
git status
# On branch master
nothing to commit (working directory clean)
git branch new_feature
git checkout new_feature
Switched to branch 'new_feature'
ls
a.txt b.txt
echo "hello c" > c.txt
git add c.txt
echo "hello a, new version" > a.txt
git status
# On branch new_feature
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: c.txt
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: a.txt
#
git commit -m "Added new feature"
[new_feature 1ccda31] Added new feature
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 c.txt
git checkout master
M a.txt
Switched to branch 'master'
cat a.txt
hello a, new version
Why does changes on a.txt get pulled into master automatically on checkout? Isn't this the purpose of 'merge'? I thought working on a branch and then switching to another one would be isolated...