2

How do you pull from existing Bitbucket GIT repo using Visual Studio 17?

Error "git failed with a fatal error. 'xyz' repository not found "

  1. I added this Misty BitBucket Extension from the marketplace
  2. Then I added the Git remote string as below with three types of options and this help page.

First I tried this string -> https://<repo_owner>@bitbucket.org/<accountname>/<reponame>.git & https://<repo_owner>@bitbucket.org/<accountname>/<reponame> then I tried the URL path based on youtube videos & the over settings page https://bitbucket.org/myrepo/xos/src


  1. I get errors that the repo does not exist.

Would appreciate some help on how to setup/pull/fetch/sync code from Bitbucket.

Error from Console

Update 1: the error after adding the Clear Credentials Tool & extracting the SSHkey

Update 2: @Marina-Liu, even after hitting connect, bitbucket connection does NOT show up in Visual Studio 2017

Transformer
  • 6,963
  • 2
  • 26
  • 52

2 Answers2

7

If you are a user of the bitbucket repo, please make sure you have permission to clone the private repo. And then you can pull the bitbucket repo’s changes to the local existing repo.

  1. Login bitbucket.

VS -> Manage connections -> login the bitbucket repo.

enter image description here

And you can also clone a bitbucket repo directly after login.

enter image description here

  1. Add bitbucket repo as remote.

In VS -> open your local repo -> in the right-bottom corner of VS -> it lists your repo folder name and branch name -> Team Explorer -> Settings -> Repository settings -> add remotes -> add a remote name (such as bit) -> input your bitbucket repo url (the format is https://bitbucket.org/account/reponame) -> save.

enter image description here enter image description here

  1. Pull changes from bitbucket repo to the local existing repo.

Fetch changes from bitbucket repo first:

Team explorer -> Sync -> Fetch -> select the remote name you just added (such as bit) -> Fetch.

enter image description here

If the local existing repo has not the origin remote, you can pull changes from bitbucket repo directly. If the local repo has other remote(s) except bit, you should merge bitbucket repo's changes into the local branch:

Team explorer -> Branches -> Merge -> assume merge bit/master into master branch -> merge.

enter image description here


To clone the bitbucket repo by command line, you can follow below steps:

  1. Clear existing credential

Credential Manager -> Windows Credentials -> remove all the credentials about bitbucket.org

enter image description here

  1. Clone by command line

Now you can clone the butbucket repo by command git clone https://bitbucket.org/account/reponame directly, it will let you to input your email address and password.

Facundo Colombier
  • 3,487
  • 1
  • 34
  • 40
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • must be a bug, when I hit connect on the `1`step, the Bitbucket `login` does not show up inside VS 2017 – Transformer Jan 19 '18 at 06:48
  • Did you cloned the bitbucket repo on your local machine? you can you verify it by git command directly `git clone https://bitbucket.org/account/reponame`. If you have permission to clone, then start from step2 is also ok. – Marina Liu Jan 19 '18 at 06:54
  • When I click `manage connections`, it *only shows TFS connections*, and only TFS login option in the Modal for TFS servers. Are you asking if I typed this on console inside VS. I am not even able to clone the repo (yes its private repo) - how can I clone a private repo from command line? – Transformer Jan 19 '18 at 06:57
  • And it seems the bitbucket extension is not installed on your VS version as the screen shot shows. If you installed the extension on the VS version you used, when you click Manage connection (the green button/icon, next to the Home icon), the bitbucket extension should be showed. – Marina Liu Jan 19 '18 at 07:00
  • I added the way to clone repo by bitbucket, you can have a try. – Marina Liu Jan 19 '18 at 07:09
  • It was installed, I uninstalled and reinstalled. Finally, I had to clear my MEF cache, there is a bug in the extension, its been reported by many people. – Transformer Jan 21 '18 at 21:42
3

You would need https://bitbucket.org/<user>/<repo>, without the final /src.

And make sure it is not a private repo, or that you are its owner, or you would not be able to access it.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • yes, its a `private repo`, how would I clone/pull from that. is there a way to sync from command line and set the string there in the command line.. the help is just horrible for Visual Studio and bitbucket – Transformer Jan 19 '18 at 05:36
  • 1
    @transformer Are you the owner of that private repo? – VonC Jan 19 '18 at 05:40
  • no, I am one usr, and have credentials. However, in VS17, I only see credentials for TFS when I hit the connect button. So, I overrode the global settings & then added remote string – Transformer Jan 19 '18 at 05:42
  • 1
    @transformer Outside of VisualStudio, can you check if Git is configured with a credential helper? (see https://stackoverflow.com/a/42152514/6309) – VonC Jan 19 '18 at 05:44
  • Since i have a couple repos/solns under different online versioncontrol, i.e `VS TFS online` and now `Bitbucket`, will this be a problem to work on both/switch back and forth. 1) I am asking because if I clear this will it wipe out my previous creds. 2) what is the credential helper/tool doing for me, is it another version control tool? – Transformer Jan 19 '18 at 05:49
  • @transformer the Windows credential manager would store your credentials per repo hosting service: do you have multiple account for Bitbucket? – VonC Jan 19 '18 at 05:50
  • @transformer Also, you could use an SSH URL to avoid all this (with a private key without passphrase) – VonC Jan 19 '18 at 05:50
  • I open to any suggestion that easy to maintin on my win desktop. I have one bit bucket repo for now – Transformer Jan 19 '18 at 05:52
  • @transformer Then creating an SSH key (https://stackoverflow.com/a/47464008/6309) and registering your public key to your Bitbucket account might be easier. – VonC Jan 19 '18 at 05:53
  • I added the tool, and ran the command, not sure what I need to do here, many options popped up. – Transformer Jan 19 '18 at 05:54
  • If you copy from https://stackoverflow.com/a/47464008/6309, there won't be any option: it will create the SSH key. – VonC Jan 19 '18 at 05:55
  • I created the key and named it bitbucket.ssh, how do I get VS to use it, what do I do next? – Transformer Jan 19 '18 at 06:01
  • @transformer if you dodn't have any previous ssh keys, no need to change its id_rsa defaut name. Follow https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html (make sure to not enter any passphrase, not needed here) – VonC Jan 19 '18 at 06:17
  • @transformer Did you follow https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html ? – VonC Jan 19 '18 at 07:07