Как рабочий каталог обновляется при «git checkout»?

Примите во внимание следующая "история":

$ mkdir my_project
$ cd my_project
$ git init
Initialized empty Git repository in /home/misha/misha/my_project/.git/

$ echo "first line" > hello.txt
$ git add hello.txt
$ git commit -m "first commit"
[master (root-commit) 9c913a1] first commit
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello.txt

$ git branch new_feature
$ git checkout new_feature
Switched to branch 'new_feature'
$ echo "second line" >> hello.txt
$ cat hello.txt
first line
second line

$ git checkout master
M    hello.txt
Switched to branch 'master'
$ cat hello.txt
first line
second line

Почему hello.txt имеет два линка es на ветке master ? (Я думал, что git checkout вернет рабочий каталог в предыдущее состояние, то есть hello.txt будет иметь только одну строку.)

Что на самом деле происходит за кулисами с рабочий каталог на git checkout ? Как он обновляется?

14
задан Misha Moroshko 26 October 2011 в 12:42
поделиться