1

I'm trying to clone a repo to my computer. I do the standard

git clone [link to bitbucket repo]

and then call

git branch -a

to see my remote branches, which shows

remotes/origin/develop

which is the branch I want to checkout into. However, when I type

git checkout develop

I get an error that says

error: invalid path '.\api-log\api.log'

and it fails to create the local develop branch. Is this happening because there is something wrong with the file? If so, how can I fix/remove the file so that the clone will go through? All the work is in the develop branch and nothing in the master.

I'm using Windows.

Apologies if this has been answered before but I couldn't find anything.

Benjamin Salerno
  • 107
  • 1
  • 13
  • What was that random file in the repo? – Schwern May 19 '21 at 19:30
  • @Schwern .\api-log\api.log – Benjamin Salerno May 19 '21 at 19:33
  • 3
    Does this answer your question? [github/git Checkout Returns 'error: invalid path' on Windows](https://stackoverflow.com/questions/63727594/github-git-checkout-returns-error-invalid-path-on-windows) – Kraigolas May 19 '21 at 19:44
  • @Kraigolas I don't think so, I don't think there's any problem with the filename like a : or aux...But I did run the git config that post suggested and it didn't change anything. – Benjamin Salerno May 19 '21 at 19:49
  • 2
    It's not at all clear to me why Windows thinks that's an invalid path, but I don't use Windows. The murky suspicion I have is that the path contains literal backslash characters as part of a file name, and Windows cannot handle that. You would have to examine the commit directly (`git ls-tree -r`) and/or Git's index (`git ls-files`) to confirm this. – torek May 20 '21 at 03:09
  • 1
    Whatever the case may be, Git *can* deal with the repository; it's just that *Windows* cannot extract the files using the names that are listed in the repository. This is painful to deal with, with the one rare exception: if you can just *delete* the file with the bad name, use `git rm --cached` to do that, and then commit. – torek May 20 '21 at 03:10

1 Answers1

0

I don't know exactly why this happen but I suggest you to remove the offending file from the repository history by the wonderful BFG tool.

At this url https://rtyley.github.io/bfg-repo-cleaner/ you can get the software and the documentation.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74