Вот последовательность команд, которые я запускал:
Здесь я на мастере.
$ git branch
* master
Создание файла в ветке master и его коммит.
$ echo "hello world, from master." > helloworld.sh
$ git add helloworld.sh
warning: LF will be replaced by CRLF in helloworld.sh.
The file will have its original line endings in your working directory.
$ git commit -m "Adding helloworld.sh"
[master e15289b] Adding helloworld.sh
warning: LF will be replaced by CRLF in helloworld.sh.
The file will have its original line endings in your working directory.
1 file changed, 1 insertion(+)
create mode 100644 helloworld.sh
$ git status
On branch master
nothing to commit, working directory clean
Создание новой ветки с именем firstbranch
.
$ git branch firstbranch
$ git checkout firstbranch
Switched to branch 'firstbranch'
$ ls
helloworld.sh
Добавляем код в helloworld.sh
:
$ echo "hello world, from firstbranch" >> helloworld.sh
$ cat helloworld.sh
hello world, from master.
hello world, from firstbranch
Вернитесь к master
:
$ git checkout master
M helloworld.sh
Switched to branch 'master'
Проверьте содержимое helloworld.sh
в ветке master:
$ cat helloworld.sh
hello world, from master.
hello world, from firstbranch
Это меня совершенно удивило! Я думал, что изменения в firstbranch
не будут здесь отражены, пока я не сделаю слияние. Я даже не зафиксировал свои изменения в firstbranch
, но они все еще появляются в ветке master
. Что тут происходит?
git status
в обеих ветвях, вы заметите, что файл изменен в обеих. - person Jepessen   schedule 13.06.2014