Repository Randomly Fails to Push
Asked by SilhouetteBucket:

I've been working on a project and prior to this year I've never had any problems with SourceTree or BitBucket but now I'm regularly and randomly encountering an issue where I start to push to my repository only to have it never finish the push.

I have no idea what causes this as it's seemingly random. Sometimes it eventually goes through or in cases like right now it just appears that it is never going to update. The last time it got this bad I had to clone the repo and push to the new repo instead and delete the old one, which isn't a practice I want to get in the habit of constantly doing.

Further complicating things, I attempted to use SSH to see if that would offer a more consistent connection for pushes and while I've followed all of the documentation to the letter (as far as I can tell) when I attempt to push I get an error message and I'm told "permission denied (publickey)" which might just be the least helpful message ever. Is the public key bad? The wrong type? Not setup properly?  

The solution seems to be to go through a verbose version which is a million lines long and doesn't seem to contain the solution.

All I want to do is push \< 1MB of data to my repo. I've spent hours trying to figure this out.

Any help would be appreciated because I don't understand at all why this would be happening.

For additional information: When this happens and I attempt to push to other repos on the same exact account they work. I have no idea what it is about this particular project that keeps tripping up the system.


Answers:
author: Theodora Boudale
body: Hi and welcome to the community!

I suggest trying to push outside of SourceTree first, to narrow down whether this is a SourceTree-specific issue or not.

Open a terminal application on your computer (not SourceTree's terminal, outside of SourceTree), navigate to the directory of this repo's clone and try to push. If you experience issues from terminal as well, what output do you get from the push command? Do you use HTTPS or SSH at the moment?

With regards to the "permission denied (publickey)" error:

* Please ensure that the public SSH key is added to your Bitbucket account here: <https://bitbucket.org/account/settings/ssh-keys/>  

* Assuming that you use OpenSSH, add the following to the \~/.ssh/config file on your computer (if the file doesn't exist you can create it)  

  ```
  Host bitbucket.org
      AddKeysToAgent yes
      IdentityFile ~/.ssh/{ssh-key-name}
  ```

  <br />

  where {ssh-key-name} is the name of the private SSH key, whose public key you have added to your Bitbucket account. This key should exist in the \~/.ssh directory on your computer.

Kind regards,  
Theodora

comments: author: SilhouetteBucket
body: Thank you for the response, Theodora. I'm sorry it took me a while to get back to you on this, but I found a workaround so I kept moving. That said, I keep hitting this issue and having to use the workaround so I'm still hoping to get to the bottom of it.

When I attempted SSH I did follow the instructions on the bitbucket pages to the letter (again, as far as I could tell) which included adding the public key to my account - it still did not work. I'll try adding that additional code, but I'm seriously confused.

I have since downloaded GitHub Desktop and pushing from there does work, but it also creates an additional "branch" (put in quotes because I don't think it actually creates anything) called "origin/HEAD". Once it does this and pushes, everything seems to be caught up.

A point that may help us narrow down whatever is happening with SourceTree is that the issue seems to be linked to when I'm pushing NEW files as part of the push. If I'm merely modifying old files, the push goes through. If I'm ADDING anything at all, suddenly it stops working.  

No idea why that would be the case. I don't have any settings that prevent me from adding files (as far as I know) and the files I'm adding are usually text-based and tiny - we're talking kb here.  

I don't think I should \*need\* to use SSH in order to make this work, but I'm happy to give it another shot - it's also confusing that it only seems to fail when it's new files.  

The last thing I'll mention is that I do use a VPN, but when I've turned it off, it still doesn't work. I suppose it's possible that BitBucket flags your account if you use one at all? But that would be a pretty bad practice since I think a lot of engineers use one at this point. It also wouldn't make sense because I can use GitHub Desktop just fine to push whether the push has new files or my VPN is on or not.  

Incredibly confusing. Thanks again for trying to help so far.


author: Theodora Boudale
body: Hi,

If you can push from GitHub Desktop commits that fail to be pushed from SourceTree, then the issue seems to be specific to the application. If this had something to do with your Bitbucket account, the push would fail from other Git applications as well and it would also fail from a terminal outside SourceTree (which, I understand, that you haven't tried yet).

I specialize in Bitbucket Cloud so I can't offer much help for SourceTree-specific issues; I suggest creating a question in the SourceTree collection here:

<https://community.atlassian.com/t5/Sourcetree/ct-p/sourcetree>

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud