question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve error message when push to hub fails because it is not a git repo

See original GitHub issue

Is your feature request related to a problem? Please describe.

I can’t figure out which folder I need to modify to get a push_to_hub to work. I would like to improve the already excellent error message:

/usr/lib/python3.8/site-packages/huggingface_hub/repository.py in clone_from(self, repo_url, token)
    760                 # Check if the folder is the root of a git repository
    761                 if not is_git_repo(self.local_dir):
--> 762                     raise EnvironmentError(
    763                         "Tried to clone a repository in a non-empty folder that isn't a"
    764                         " git repository. If you really want to do this, do it"

OSError: Tried to clone a repository in a non-empty folder that isn't a git repository. If you really want to do this, do it manually:
git init && git remote add origin && git pull origin main
 or clone repo to a new folder and move your existing files there afterwards.
OSError: Tried to clone a repository in a non-empty folder that isn't a git repository. If you really want to do this, do it manually:
git init && git remote add origin && git pull origin main
 or clone repo to a new folder and move your existing files there afterwards.

Describe the solution you’d like

I would like the self.local_dir variable to be interpolated into the error message:

"Tried to clone a repository in a non-empty folder that isn't a"
f" git repository ('{self.local_dir}'). If you really want to do this, do it"

Describe alternatives you’ve considered

None

Additional context

None

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
payotocommented, Nov 18, 2022

Happy to implement the suggested fix

0reactions
Wauplincommented, Nov 19, 2022

Ok, thanks for the input 😃 I approved the PR. Have a nice weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix 'failed to push some refs to' Git Errors - Komodor
If you get a failed to push some refs to error, the main thing to do is git pull to bring your local...
Read more >
Not a git repository" when attempting to remote add a Git repo
In my case, I came across this error when running "git status" in a repo whose ownership was set to root:root. Running "git...
Read more >
Git error - Fatal: Not a git repository and how to fix it | Datree.io
This error means you attempted to run a Git command, but weren't inside a Git repository. Make sure you've: Navigated to the right...
Read more >
Fix Git's 'fatal: repository not found' error quickly | TheServerSide
Frustrated by Git's 'fatal: repository not found' error message? Here are five ways to fix that problem and successfully clone, fetch and ......
Read more >
Raise exception when git push fails · Issue #621 - GitHub
Having to perform bit operations on flags is very unintuitive. The command line git client fails when push fails.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found