2

I have a repository which I use from both Windows and Linux systems. Everything was working but now I have the following error on git pull, on the Windows system.

error: invalid path 'cse5441_lab1/main.'
Updating b69442e..8dad691

It does pull a few other files though.

git status shows I am 39 commits behind.

I am guessing the last . in cse5441_lab1/main. is invalid name for a file on Windows. If so, how can I solve this issue?

User 10482
  • 855
  • 1
  • 9
  • 22

3 Answers3

1

Best way is to checkout the branch on a linux machine, rename the file in question, then commit and push it.

Afterwards there should be no problems any more on Windows.

MrTux
  • 32,350
  • 30
  • 109
  • 146
0

If you want to checkout just the files with valid paths, you can do (in Git Bash):

git clone --sparse -c core.protectNTFS=false -n <repo-URL>
git sparse-checkout add "\!<pattern1>" "\!<pattern2>"
git checkout <branch>

Patterns are relative to repo root and can use *

More info here and here.

However if you actually need those files to e.g. build the project, my best bet to do this on Windows would be to use WSL.

In your particular case, if you are the only repository user, you can just rename the file on your Linux system.

Roman Orekhov
  • 330
  • 2
  • 6
-1

The error indicates that there are some conflicts on the update.

Try using the following command: git reset --hard origin/master

The above git command will throw away all your staged and unstaged changes, and everything on your current local branch and make it exactly the same as origin/master.

if you want to pull from different branch other than the master then just change the branch name from master to your desired branch name

Alexis Pavlidis
  • 1,080
  • 1
  • 11
  • 21
  • Getting similar error ```error: invalid path 'cse5441_lab1/main.' fatal: Could not reset index file to revision 'origin/master'.``` – User 10482 Feb 02 '20 at 18:04
  • 1
    Did you try using `Sparse checkout` ? Here is an answer that might be helpful to you https://stackoverflow.com/questions/33702140/git-pull-invalid-windows-file-names – Alexis Pavlidis Feb 02 '20 at 18:10
  • 1
    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:13