Jestem naprawdę nowy w git i próbowałem zrozumieć, dlaczego git ciągle pokazuje wszystko, co zmieniłem w jednej gałęzi w innej, kiedy uruchamiam git checkout, aby przełączać się między gałęziami. Najpierw próbowałem nie używać git add i nie działało. Jednak próbowałem wtedy użyć git add, ale nie rozwiązałem problemu. Nie używam jeszcze git commit.
Oto co robię:
$ 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")
Pomyślałem, że podczas korzystania z gałęzi, cokolwiek robisz w jednej gałęzi, jest to niewidoczne dla wszystkich innych gałęzi. Czy to nie jest powód tworzenia oddziałów?
Próbowałem użyć "git add", ale zmiany są widoczne w obu gałęziach. Czy muszę uruchomić „git commit” przed przełączeniem się między gałęziami, aby tego uniknąć?