Home > Software engineering >  Git "error : invalid path" during git checkout
Git "error : invalid path" during git checkout

Time:11-27

When I'm trying to checkout to another branch from cmd:

git checkout Datascience_With_Python --

this error is occuring:

error: invalid path 'Datascience_With_Python/Machine Learning/Tutorials/Steps for Machine Learning "MLOps"/README.md'
error: invalid path 'Datascience_With_Python/Machine Learning/Tutorials/Steps for Machine Learning "MLOps"/Steps_For_Machine_Learning_MLOps.ipynb'

I think this is because of the inverted commas in the folder name 'Steps for Machine Learnin "MLOps"' But I can't edit it because it is an open-source project and I am only allowed to work on a particular folder in a particular branch.

I tried:

git clone --sparse -c core.protectNTFS=false -n <repo-URL>
git checkout <branch>

but its deleting all the folders from my local clone of the repo.

I also tried :

git config core.protectNFTS false
git config core.sparsecheckout true

But it also didn't work.

Please help...

CodePudding user response:

Before Checkout the Branch Check the list of all branches 1 git branch ( Now your View the List of All branches * character is with your active branch) 2 git checkout development (in which branch you want to shift simply)

CodePudding user response:

"inverted comma":

The issue also includes the use of double-quotes in "MLOps", and part of the list of characters an OS like Windows would not support in file names.

Following "Fixing Invalid Git Paths on Windows" from Brendan Forster, you could:

git checkout -f Datascience_With_Python --

With -f:

When switching branches, proceed even if the index or the working tree differs from HEAD, and even if there are untracked files in the way. This is used to throw away local changes and any untracked files or directories that are in the way.

When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored.

In your case, that should give you a detached HEAD, with the problematic path "deleted".

Create a fix branch from there, work and commit.

But you won't be able to restore Steps_For_Machine_Learning_MLOps.ipynb without fixing its parent folder name.
So you can try and push that fix branch, with a warning for other users when they will merge it, as they need to restore the missing file (hopefully not on Windows, since they wouldn't be able to clone it in the first place).

  • Related