I am facing issues with the git checkout command. Please help.
Here is what I did.
Lists of commands used and the error details:
git clone [my repo] git checkout -b b01
Hereafter I made multiple changes, including creating new files and directories, committed those changes and successfully pushed the changes on that branch to the repo. like:
git push -u origin b01
Now I am done with the changes and want to merge it to the master branch. So I do a:
git checkout master
Here is the error it throws:
fatal: cannot create directory at 'workfolder': Permission denied
Git keeps me in b01, but deletes ALL the files I had created in the branch. So if I now do a
git status
it shows me:
On branch b01 Your branch is upto date with 'orgin/b01' Changes not staged for commit: (use "git add/rm .....) deleted: new file1 deleted: new file2 <list of the new files I had added but which got deleted as a result of the command>
I am having to run a
git checkout -- .
to restore the files.
Please help.
There are a couple of possible solutions to this issue: Create a folder that the user running the build has permissions to. Change the ownership of the directory with the chown command before trying to write to it.
Git Checkout File Checking out a file is similar to using git reset with a file path, except it updates the working directory instead of the stage. Unlike the commit-level version of this command, this does not move the HEAD reference, which means that you won't switch branches.
I had a similar situation. Though it was due to me having the solution open in visual studio. Closing visual studio and doing a git reset put me into a good spot.
I.e. check to see if any processes are locking the folder/files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With