I am new to git and trying to wrap my head around the way branches work. According to the documentation git checkout
Updates files in the working tree
When you create a branch, that branch will automatically get the files of the branch you were in when you created this new branch.
Let's say you are in master branch and you want to create a develop
branch. All together should look like this:
git checkout -b develop # create and switch to develop branch
touch text.txt # create a file
git add . # add file to staging area
git commit -m "adding text.txt"
git checkout master
And then you won't see text.txt
since you are in master
.