0

I cannot clone any repository anymore.

$ git clone git@bitbucket.org:myaccount/myrep.git
Cloning into 'myrep'...
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

The thing is my ssh id_rsa key is still the same. I recreated it anyway, updated it in my BitBucket account's ssh keys, and the same error shows up when I try to clone my repository. I tried the very same procedure on another machine (redhat) and git clone worked. So there is something happening with git.

Then I went in another git versioned project:

$ cd share-repo

$ ls -a
./          ../         .git/       .gitignore* f1*         f2*

I print the git config file:

$ cat .git/config
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git@bitbucket.org:myaccount/share-repo.git
[branch "master"]
[user]
    name = myaccount

I try a pull:

$ git pull -v
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Okay let's try a a push?

$ git push -v origin master
Pushing to git@bitbucket.org:myaccount/p2.git
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Huh? Git tries to push to repository p2? It should try pushing to share-repo... How in the hell is it trying to push to a repository which name is p2? Indeed, I had a repo named p2 this morning, but I deleted it from my BitBucket account while doing some tests, then I removed the related folder p2 from my computer. How did git retain information about p2? And above all, where is it stored, how can I reset it?

$ git remote -v
origin  git@bitbucket.org:myaccount/p2.git (fetch)  # ?!
origin  git@bitbucket.org:myaccount/p2.git (push)   # ?!
origin  git@bitbucket.org:myaccount/share-repo.git (push)

Strange, as we saw previously the git config file only holds information regarding the repo share-repo. Also I tried locating the string p2 in the whole folder:

$ grep -Rin p2 ../share-repo/
# Nothing

I manually recreated a repository named p2 in Bitbucket. I tried to clone it:

$ cd ..

$ git clone git@bitbucket.org:myaccount/p2.git
Cloning into 'p2'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

$ cd p2

$ cat .git/config 
[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@bitbucket.org:myaccount/p2.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

$ git remote -v
origin  git@bitbucket.org:myaccount/p2.git (fetch)
origin  git@bitbucket.org:myaccount/p2.git (push)
origin  git@bitbucket.org:myaccount/p2.git (push)

Okay, the git clone worked, but now it referenced two extra lines for the remotes, one of which is duplicated. Remember those extra lines when working with the repo share-repo? It's about those very first two lines which are still related to the old p2 repo I had deleted.

Let's try to push some changes:

$ git touch .gitignore

$ git add .gitignore

$ git commit -m "first commit"

$ git push -v origin master
Pushing to git@bitbucket.org:myaccount/p2.git
Counting objects: 3, done.
Writing objects: 100% (3/3), 216 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@bitbucket.org:myaccount/p2.git
 * [new branch]      master -> master
updating local tracking ref 'refs/remotes/origin/master'
Pushing to git@bitbucket.org:myaccount/p2.git
To git@bitbucket.org:myaccount/p2.git
 = [up to date]      master -> master
updating local tracking ref 'refs/remotes/origin/master'
Everything up-to-date

So git pushed to repo p2, and tried to do so a second time since the two repos have the same name and same location on my bitbucket account, so it obviously found that everything was up to date.

Now I could clone any repository I want, provided the repo p2 exists in my Bitbucket account. If I wanted to push some changes in let's say share-repo, it would work, but git would also try to push the same changes to the repository p2. That's quite a mess I got myself into and I don't know how to solve it.

To sum up, I had this morning a repository called p2 which I deleted from bitbucket, then I deleted it's folder from my computer. Since then, whichever git project I cd into, git remote -v shows me it has stored - somewhere - information related to the late repo p2, on top of the current repo I am working on. Git updating commands - clone, push, pull - won't work unless I create back this damn repo p2 on Bitbucket. Once I do so, git updating commands will apply the commands to the current repo I'm working on, as well as to the repo p2.

p2 is not the only repository I deleted today, so I am quite curious to know what happened here.

I will gladly take all the help I can get.

  • 1
    check ~/.gitconfig for a [remote "origin"] section. – Patrick Jul 9 '16 at 5:36
  • No way... I had looked for a ~/.git file using tab completion and did not find any. Now looking carefuly (ls -a ~/) there is indeed the ~/.gitconfig file with the information on that remote. Thanks a lot. Don't you want to make an answer on that, so that I validate it? – kaligne Jul 9 '16 at 9:57
1

Solved. I am speechless. I had made a quick check for a ~/.git-whatever file using bash autocompletion (tab), it did not work so I blindly assumed the issue was somewhere else. Patrick's comment shed the light: I carefully checked using ls -a ~/, the ~/.gitconfig he wrote about really is here, and it holds the information regarding the remote:

$ cat ~/.gitconfig
[user]
   name = myaccount
   email = me@domain.com
[remote "origin"]
   push = git@bitbucket.org:myaccount/p2.git

And now I remember the cause for this: while experimenting I used the command git config --global remote.origin it@bitbucket.org:myaccount/p2.git and I changed other global configurations. I just did not understand what the --global did as I found no alteration in the repo/.git/config file.


Additional doc on git configuration: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.