You can’t clone a Bitbucket repo using GithHub Desktop directly. Instead you would have to:
- Clone the Bitbucket repo locally via command line.
- Add the cloned repository to your GitHub Desktop app.
After completing these 2 steps, you’ll be able to execute sync, push, pull, commit, and other git commands available in GitHub Desktop for your Bitbucket repository just as you would for any GitHub repository.
You will need your Bitbucket repository’s git URL as available on the Overview page of your repository:
- Open Terminal app.
- Type
cd /Local/path/to/parent-folder/to/clone/into
(replacing that sample path with the local path to the parent folder you want to clone your Bitbucket repository into). - Hit enter. You’ve just opened that parent folder on the command line.
- Type
git clone https://[email protected]/path/to/your-repo.git
(replacing that sample URL with the Bitbucket URL available on the Overview page of your repository). - Hit enter and watch the repository being cloned. (Once it’s done, it’ll say something like …done in one of the last lines.)
-
Open GitHub Desktop.
-
In the upper right corner (if your sidbar is open) press the large + button.
-
Select Add to add an exisiting local repository.
-
On the Add tab click the Choose… button, navigate to the folder you have just cloned your Bitbucket repository into, and select it.
-
Your newly added repository will appear at the bottom of your sidebar in the Other section.
That’s it. You should now be able execute git operations on your Bitbucket repository via your GitHub Desktop app just as on any GitHub repository.
After setting up a Bitbucket repo and pulling it down using git from the command line of my Mac, I wanted to switch to GitHub Desktop to manage commits and push/pulls. Some of the information here was helpful, but I'll sum up what I did to get this working.
Add Local Repository to GitHub Desktop
Download the app and launch it, either logging into your GitHub account or skipping that step. Then select the Add Local Repository option (if you already setup git using the command line like I did). Find the local folder you have the repo in, and you should see that repo now in GitHub Desktop (along with it's History, if there is any yet).
Add Username to Remote
In GitHub Desktop, select the Repository option from the app menu, and select Repository Settings. You'll get a modal with the Remote for this repo. It should look something like this:
[email protected]:teamname/repo-name.git
Change the
git
part to your Bitbucket username:[email protected]:teamname/repo-name.git
And save. Now commits coming from GitHub Desktop will be made using your Bitbucket username (once we finalize authentication).
Setup SSH Agent
Using the macOS credential storer
ssh-agent
we can allow GitHub Desktop (or other software) to use our SSH key and passphrase to authenticate with other services. Open a Terminal window and type:ssh-add -K ~/.ssh/id_rsa
Where
~/.ssh/id_rsa
is the path to your SSH key. You'll be prompted to enter the passphrase associated with your SSH key.Add SSH Key to macOS Keychain
The macOS SSH agent will handle your authentication, until you restart your Mac. So to prevent from having to do this all over again on restart, add your SSH key to the macOS Keychain. You'll need to create a
config
file in the same directory as your SSH key:~/.ssh/config
And then add the following to that file:
Where
~/.ssh/id_rsa
is the path to your SSH key.Profit
Or... just use GitHub Desktop to push and pull from your Bitbucket repo.