我是新來的混帳分支和我有點通過對具有結構轉換的分支行爲混淆。執行以下步驟:爲什麼當我切換分支時git自動合併更改?
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
爲什麼a.txt上的更改會在結帳時自動拉到主服務器上?這不是「合併」的目的嗎?我以爲工作的一個分支,然後切換到另一個人會被孤立......