Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot push from Sourcetree to Bitbucket

Vito Kurnik October 25, 2019

I can't push from Sourcetree to Bitbucket even though I added a remote repository and I entered the right username and password. 

4 answers

0 votes
Vito Kurnik November 15, 2019

Hi @Mikael Sandberg

I'm back with an old familiar problem. I'm working on a group project and our Bitbucket repository was created a few weeks ago. I tried to clone it and set the destination path to my Unity project folder, but I couldn't - it said I need to choose or create an empty folder. I've decided to create a new local repository in Sourcetree and add our Bitbucket repository as a remote repository. But, when I tried to push, the old "invalid username or password" error message appeared, even though I deleted the passwd file and removed any credential related to Bitbucket. 

I know I could just clone our Bitbucket repository into an empty folder but then I'd had to move all my files from the Unity project folder into that folder and that would be exhausting. Any ideas on how to manage the situation?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 18, 2019

Make sure your password is not stored in the Windows Credential Manager too. I would recommend that you use an SSH key instead, that way you do not have to worry about passwords. Your other option is to turn off Windows Credential Manager and see if that helps.

git config --system --unset credential.helper
git config --global --add core.askpass ""

The first command disables Credential Manager for Git, the second one turns it off for openSSH.

0 votes
Vito Kurnik October 30, 2019

For anyone wondering: you will probably find your answer somewhere in the replies to the one I marked as "accepted".

0 votes
Vito Kurnik October 26, 2019

bitbucketsucks.pngThat is what I got. Here's what went down:

1. I created a new repository on Bitbucket. The "master" branch also got created in the process and it included the README.md file.

2. I then made a new repository on my computer using Sourcetree. I committed a few files and they were all in the "master" branch.

3. I added a remote repository in Sourcetree which was, of course, the one I created earlier on Bitbucket.

4. I tried to push to Bitbucket the files I just committed to the "master" branch in Sourcetree.

5. After that failed I pulled from Bitbucket (it was only the README.md file).

6. After multiple attempts, I couldn't push the files from Sourcetree to the Bitbucket repository into the "master" branch. But then I made a "new" branch and it worked but I wanted the files from Sourcetree to be in the "master" branch in Bitbucket. I tried to merge the two branches on Bitbucket but I couldn't because they're unrelated.

Apart from the error message screenshot, I'm also adding the screenshots from Sourcetree and Bitbucket.srctree.PNGbb1.PNGbb2.PNG

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2019

Okay, so the first error message indicate that your username or password is incorrect, so you should make sure that the password stored in Sourcetree and Windows Credential manager is correct. 

Vito Kurnik October 28, 2019

I made sure of that but even after that, I wasn't able to push the files which I committed to the "master" branch in Sourcetree to the "master" branch in Bitbucket. I didn't capture that error message though - I hope you might still be able to help me anyway considering my description of what went down. 

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2019

There are lots of things that can prevent you from pushing to a specific branch, for example branch permissions, hooks, etc. Do another push of master and see what error message you get.

Vito Kurnik October 28, 2019

error2.PNGThat's what I get. Even after I performed the action "pull" (a few days ago when this problem occurred and I had to "make a compromise" to finish my school work) I still couldn't get the files to be pushed into the "master" branch on Bitbucket. It was sort of untouchable, so to speak. And the only way to not get the invalid username/password error for me is to include username:password in the link to the repository on Bitbucket which isn't very private since I have to take screenshots for my school work. I was trying to sort things out in Sourcetree in Authentication bar in Tools>Options, but these credentials, or whatever you want to call them, confuse me, the whole process does.  

 

All want to know (with simple and plain instructions, not like those tutorials where they just go on blabbing about this and that and so on) is how I can create a repository on Bitbucket, create a remote repository in Sourcetree so I can push to the repository on Bitbucket (to any branch I desire) and how to set the credentials right so that I don't have to deal with any errors.

Thank you in advance.

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 28, 2019

I think I know what got you into this issue in the first place, you created a new repository locally instead of cloning the remote repository. This would also explain why you could not merge your changes into master in Bitbucket.

Okay, so here is the simple guide you are looking for to create a repository and clone it:

  1. In Bitbucket, create a new repository.
  2. Clone the repository, either by copying the URL or by clicking Clone in Sourcetree
  3. Add your files to the repository and commit them
  4. Push everything back to Bitbucket
Like Steve_Potocny likes this
Vito Kurnik October 28, 2019

Believe it or not, I've tried that before as well. But, a familiar error message appeared:cloningerror.PNG

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2019

So try this, go to c:\users\<your user ID>AppData\local\atlassian\sourcetree and remove the passwd file. Then go to Credential Manager (under control panel) and remove any references to Bitbucket. If you now do another clone you should be asked to enter your Bitbucket password. 

You could also try and setup a SSH key, that way you do not have to deal with usernames and passwords for Bitbucket. You can find the instructions on how to do that here: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

Like Vito Kurnik likes this
Vito Kurnik October 29, 2019

Thank you! I know this was a lengthy back and forth discussion but I was able to clone the repository, commit files and push to Bitbucket with no problem. Thank you again :)

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 30, 2019

You are most welcome, glad it got solved!

Like Vito Kurnik likes this
Tien Le July 15, 2022

Darn!  Even tried restarting laptop and Sourcetree is still wanting to log in with username and password (after setting up SSH key successfully) and fails.  Now what?  Thanks,

Tien

0 votes
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2019

Hi @Vito Kurnik,

Welcome to the Atlassian Community.

Do you get an error message when you try and push? And if so, what is that error message? 

Vito Kurnik October 26, 2019

Hi, @Mikael Sandberg I have included the error message screenshot and some other details in my answer down below.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events