Can't open file in working respository

$ git status

On branch mycode

nothing to commit, working tree clean

$ git checkout -b mycode

fatal: A branch named 'mycode' already exists.

$ git fetch

$ intro-python/git-basics/change_me.txt

-bash: intro-python/git-basics/change_me.txt: Permission denied

$ git status

On branch mycode

nothing to commit, working tree clean

lol, sorry. I have no idea. This is my first day with git. My computer rebooted. I went back to the intro guide I was following. I changed the file with vi. Did a git diff and nothing came up. Tried to do a git commit and that is what I got.

I was confused on what it meant to be in the working tree. I thought I had to check out the file after I logged in. I downloaded Atom and then opened it in there, and then I could see what was going on. The original changes I had made prior to the reboot did not save. I thought that the intro-python/git-basics/change_me.txt would allow me to check out the file. I didn’t have to check out the file, because you said I’m already in the directory. I had to use text editor to actually edit the file and then I could make changes, add and commit. Basically I didn’t understand the fundamental principle of how this is working with the checkout.

You do not check out files to work on them. You checkout a branch to work on the files in that branch.

1 Like