A branch is the history moving forward on a separate line. When you try out a new feature you do not want to break the main branch (main): you open a branch and commit there, and main stays where it is, in working order.
git branchgit switch -c fix/logingit add login.pygit commit -m "Fix empty password check"git switch main
git branch lists the branches and marks the one you are on with a star. git switch -c name opens a new branch and moves to it; git switch name moves to one that exists. Commits are added to the branch you are on at that moment.A branch is really a very light thing: a label pointing at a commit. Opening one copies nothing. When you switch branches the files in the folder go back to how they are in that branch's last commit; on moving to main the file you added on the other branch disappears from view, but it is not deleted: it is on its branch.