Eu sou realmente novo no git e estou tentando entender por que o git continua mostrando tudo o que eu mudei em um branch em outro branch quando executei git checkout para alternar entre os branches. Primeiro, tentei não usar git add e não funcionou. No entanto, tentei usar git add, mas não resolvi o problema. Não estou usando o git commit ainda.
Isso é basicamente o que estou fazendo:
$ 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")
Eu pensei que, ao usar ramos, tudo o que você faz em um ramo, é invisível para todos os outros ramos. Não é por isso que se criam ramos?
Tentei usar "git add", mas as alterações são visíveis em ambos os ramos. Preciso executar "git commit" antes de alternar entre branches para evitar isso?