Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal: not a git repository #467

Open
MohamedTalhaoui opened this issue Jul 7, 2023 · 3 comments
Open

fatal: not a git repository #467

MohamedTalhaoui opened this issue Jul 7, 2023 · 3 comments

Comments

@MohamedTalhaoui
Copy link

MohamedTalhaoui commented Jul 7, 2023

Hound seems to issue git commands from outside git directory leading to "fatal: not a git repository"
Logs from hound show:

2023/07/07 14:27:08 could not determine target ref in /data/db/vcs-270dba66bc21b8aa808f68f2da4c3ca5f830b0b2. Will fall back to default ref master
2023/07/07 14:27:08 Failed to git fetch /data/db/vcs-270dba66bc21b8aa808f68f2da4c3ca5f830b0b2, see output below
kex_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

I am running it inside a K8S pod and did the following test:

#Not Working
~ # git fetch /data/db/vcs-270dba66bc21b8aa808f68f2da4c3ca5f830b0b2
fatal: not a git repository (or any of the parent directories): .git

#Working
~ # cd /data/db/vcs-270dba66bc21b8aa808f68f2da4c3ca5f830b0b2
/data/db/vcs-270dba66bc21b8aa808f68f2da4c3ca5f830b0b2# git fetch
Warning: Permanently added 'git.xxx.com, xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts.

/data/db/vcs-553ae5ae46c459454992a9012b25da44e30c8bed # env | grep GIT
GIT_SSH_COMMAND=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /etc/ssh-key/id_rsa 
GITLAB_TOKEN=xxxxxxxxxxxxxxxxxxxx

#Added this one but did not help
GIT_DISCOVERY_ACROSS_FILESYSTEM=1

I am confused because some repo works and other don't.

@userbradley
Copy link

If it's makes you feel better, I get this too. We get the below

2023/11/14 16:25:26 Failed to git reset /data/data/vcs-3e0ca7987215362f21e06937b5469422c298cf54, see output below
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Continuing...

all our repos use main... awkward

@salemhilal
Copy link
Contributor

Hey gang, I think these are different problems.

@MohamedTalhaoui, it looks like Hound is attempting to fetch that repo, but fails to make an SSH connection (that's what I'm assuming based on kex_exchange_identification in that error log). Is your repo private, and does an http request work?

@userbradley we updated Hound to look for the default ref and use that if it's set in #345. While git (unfortunately) still defaults to master, it should detect a default ref if you have one set. If not, try setting the branch to be "main" in your config and see if that works.

@MohamedTalhaoui
Copy link
Author

@salemhilal you are right, in my case it was definitely a SSH issue.
I was not able to find the root cause, I can only see connections to my GitLab private instance are reset.
So, I have managed to workaround it by using https and an access token.
This is not very secure though, since the access token appears in clear text in the hound config files and all the links generated on the search result page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants