Git: should branches isolate changes or shouldn't?

I thought I already had a decent understanding of Git, but now I was surprised. I thought that branches would isolate changes from other industries, so I started a lot of experimental refactoring in a new industry. This refactoring involves moving many files. When I switched to the wizard, I could still see the changes!

I went to my inbox to replicate the problem:

$ git branch crazy-refactoring
$ git checkout crazy-refactoring
$ rm README
$ git checkout master
$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    README
#
no changes added to commit (use "git add" and/or "git commit -a")
$ ls README
ls: cannot access README: No such file or directory

Why? My whole goal is to create a branch so that I can try something and throw it away if it doesn’t work out. Toughts?

+5
source share
1 answer

You did not commit the deletion. Only committed changes are "isolated."

Regarding your comment:

, - , .

:

README crazy-refactoring, . Git , . , , .
Git , , . , , .

- + ( reset ).

, Git , , .

+6

All Articles