Я действительно новичок в git, и я пытался понять, почему git продолжает показывать то, что я изменил, в одной ветви в другой ветви, когда я запускаю git checkout для переключения между ветками. Сначала я попытался не использовать git add и didn ' т работа. Тем не менее, я попытался использовать git add, но не решил проблему. Я пока не использую git commit.
Это в основном то, что я делаю:
$ git clone <a_repository>
$ git branch
* master
$ git branch testing
$ git checkout testing
...edit a file, add a new one, delete...
$ git status
# On branch testing
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file1.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git branch
master
* testing
$ git checkout master
D file1.txt
Switched to branch 'master'
$ git status
# On branch master
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: file1.txt
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# file2.txt
no changes added to commit (use "git add" and/or "git commit -a")
Я думал, что при использовании веток, что бы вы ни делали в одной ветке, это невидимо для всех других веток. Не в этом ли причина создания веток?
Я пытался использовать "git add", но изменения видны в обеих ветках.
Нужно ли запускать «git commit» перед переключением между ветками, чтобы избежать этого?