38

I'm getting the following errors in Git using BitBucket:

conq: repository does not exist.
fatal: The remote end hung up unexpectedly

How do I rectify this issue? I've carried out the following:

git init .   
git remote add origin git@bitbucket.org:myname/myproject.git
git add .
git commit -m "..."

git push  <<< error occurs here

I've set-up BitBucket with the ssh key and repo is shown on dashboard.

milan
  • 11,872
  • 3
  • 42
  • 49
jaffa
  • 26,770
  • 50
  • 178
  • 289
  • Side node: I got this because VSCode thought it would be smart and replaced my spaces with `%20`'s; then as a result it was trying to execute a clone of my local file path instead of the repo name... – Andrew Nov 17 '20 at 22:36

14 Answers14

39

In my case, the git repository was duplicated somehow in the config file:

cat .git/config

gave me:

[remote "origin"]
    url = git@bitbucket.org:myUserName/myRepositoryName.git/myRepositoryName.git
    fetch = +refs/heads/*:refs/remotes/origin/*

As you can see, myRepositoryName is duplicated, so I removed that, and now the config file looks like this:

[remote "origin"]
    url = git@bitbucket.org:myUserName/myRepositoryName.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Doing this, my problem is solved. Now the push is correctly done. Hope this help someone.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Malloc
  • 15,434
  • 34
  • 105
  • 192
  • I changed the remote repository and in order to fix this I also had to removed the `/shared/cached-copy` folder. – Darme Mar 10 '15 at 15:46
28

This error also occur when you rename your repo:

Edit .git/config and change from:

git remote add origin git@bitbucket.org:myname/myproject.git

to:

git remote add origin git@bitbucket.org:myname/my_new_project_name.git
Igor Parra
  • 10,214
  • 10
  • 69
  • 101
15
git remote rm origin
git remote add origin git@github_or_bitbucket_or_whatever_link
hasentopf
  • 755
  • 1
  • 12
  • 27
15

I managed to do this in the end by removing the origin and re-adding it. Everything seemed ok after I did this.

jaffa
  • 26,770
  • 50
  • 178
  • 289
3

I had a similar problem, and this thread helped me solve the issue, but my solution is slightly different:

I was on a remote server, so first I had to change into the public_html (www) directory, then initialize the repo. (note you have to first add your .ssh key in bitbucket)

$ git init

which initialized an empty Git repository

then add the remote

$ git remote add origin git@bitbucket.org:myname/myproject.git

then I was able to pull and checkout my branch

$ git pull
$ git checkout <branch-name>
bdanin
  • 771
  • 7
  • 10
3

You get this error if the remote repository hasn't been created. Bitbucket is running a service called conq that handles pushes and you see the error message from it. Simply create a new (empty) repository and the push should succeed.

Here I'm pushing to a non-existing repository:

$ git push git@bitbucket.org:mg/testt.git master
conq: repository does not exist.
fatal: The remote end hung up unexpectedly

and here I push to the correct path:

$ git push git@bitbucket.org:mg/test.git master
Counting objects: 3, done.
Writing objects: 100% (3/3), 203 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: bb/acl: mg is allowed. accepted payload.
To git@bitbucket.org:mg/gtest.git
 * [new branch]      master -> master

The test repository was newly created on Bitbucket. If the problem persists, then I suggest deleting the empty repo from Bitbucket and re-creating it.

Martin Geisler
  • 72,968
  • 25
  • 171
  • 229
2

Did you encounter this error doing the Rails Tutorial?

I did. And I'm very new to this so I was only doing was the tutorial explicitly told me to do. That got me into trouble because in chapter 3 it says it’s a good idea to create a new repository at Bitbucket and push it up but it doesn't hold your hand through the process like it does in Chapter 2.

Don't forget to create the new repository at BitBucket before pushing to that repository.

From Chapter 2: You should also create a new repository by clicking on the “Create” button at Bitbucket.

I did that and it fixed the problem.

Chad Bingham
  • 32,650
  • 19
  • 86
  • 115
sgryzko
  • 2,397
  • 2
  • 22
  • 37
2

In my case, i changed the repo name. Therefore, i was not able to push because changing repo name also changed repo remote url. Thus,

First remove previous remote url by git remote rm origin now add new one and do push.

Hope it'll help someone. Cheers!

Danish
  • 1,467
  • 19
  • 28
1

in my case, i mixed up usernames:

in my scenario there are 2 accounts: i need to connect using my-account to the repository's owner-account:

owner-acc   - created, maintaining the account
my-acc           - me, a participant

the syntax in this case should be

url = git@bitbucket.org:owner-acc/repo-name.git

and NOT my username, nor my account-name.

I assume bitbucket's instructions I followed previously took care of identifying me somehow (it's probably relating my-account with the public key i uploaded earlier).

Berry Tsakala
  • 15,313
  • 12
  • 57
  • 80
1

I had this error when trying to deploy with Capistrano.

I was missing the deploy key for that Bitbucket repo.

Here's how to solve the issue:

  1. Generate an SSH Key on your server: https://confluence.atlassian.com/display/STASH/Creating+SSH+keys
  2. Follow these instructions to get ssh-agent running, and load in the identity you just created: https://confluence.atlassian.com/display/BITBUCKET/Troubleshoot+SSH+Issues

Once that's finished just go to the Bitbucket repo > Settings > Deploy Keys and copy and paste your newly created key.

Ken Prince
  • 1,437
  • 1
  • 20
  • 26
0

In some cases (maybe not yours) you may have to change

url = git@guthub.com:username/projectname.git/

to

url = https://github.com/username/projectname.git/

using the Nano editor, say:

nano .git/config
0

In my last case it was all related to capitals in the repo name in Bitbucket. Even when the repository name had capitals, Bitbucket was telling me to use lower case names in the git commands to push initial code. This could be related to git case handling and unix/windows case handling. Just check this if your project name has upper case letters.

Dani bISHOP
  • 1,226
  • 11
  • 18
0

I was able to solve this problem by navigating into the submodule's root directory and using the following command.

git push -v origin master

I stumbled across this at here which also has some other troubleshooting steps that may be of use.

Community
  • 1
  • 1
pat8719
  • 1,700
  • 1
  • 26
  • 47
0

My case is that the PC has saved someone's password which can't access to that repo. delete the saved credential to use jenkins' credential or grant credit to him.

That works for me.

Andy
  • 434
  • 5
  • 7