3

i have cloned the project in my windows machine(windows 10) and try to switch to different branch. but getting invalid path issue[1]

#git switch develop

[1]

error: invalid path 'src/main/resources/examples/invoice-item-create-request-eip.json '
error: invalid path 'src/main/resources/examples/invoice-item-create-request-orcl.json '

Why is that? I didn't get any issue /warning when i clone the project

Ratha
  • 9,434
  • 17
  • 85
  • 163
  • `git switch` is kind if new.... what happens if you try the old `git checkout`instead? – eftshift0 Feb 04 '20 at 03:02
  • # git checkout develop also gives same issue – Ratha Feb 04 '20 at 03:10
  • Note that these paths end with a space—the file's name is `path/to/file` and not just `path/to/file`, where I used to emphasize the blank—and your version of Git demands that no file's name can end with a space like that. Those are the names of files in the commit identified by the name `develop`; presumably, the commit identified by your current branch name does not contain files with these funny ended-by-a-blank names. – torek Feb 04 '20 at 03:50

1 Answers1

1

I didn't get any issue /warning when i clone the project

Probably because the default checked out master branch did not include files with a trailing space in it.

See if you can rename those files directly on GitHub in the develop branch (through their web GUI interface), and then clone the repository again (and switch to develop)

If you cannot rename them, exclude them through a sparse checkout (new command, still experimental with Git 2.25: I present it here).


As noted by wdtj in the comments:

if you are using sparse-checkout on Windows, you may need to add git config core.protectNTFS false per git-for-windows/git issue 2777

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • you are right master branch doesn't have those files. Only in develop branch those files are there. but, i cannot rename the files(out of my control). How can i overcome that issue in windows to switch between branches? – Ratha Feb 04 '20 at 05:37
  • @Ratha THrough a sparse checkout, in order to exclude those files: https://git-scm.com/docs/git-sparse-checkout – VonC Feb 04 '20 at 05:41
  • Note that if you are using sparse-checkout on windows, you may need to add core.protectNTFS false per https://github.com/git-for-windows/git/issues/2777 – wdtj Sep 04 '20 at 14:18
  • @wdtj Thank you for this feedback. I have included your comment in the answer for more visibility, with additional links. – VonC Sep 04 '20 at 14:21