Skip to content

Instantly share code, notes, and snippets.

@glueckpress
Last active June 3, 2024 13:31
Show Gist options
  • Save glueckpress/c53f3a07779ce7f67fe2 to your computer and use it in GitHub Desktop.
Save glueckpress/c53f3a07779ce7f67fe2 to your computer and use it in GitHub Desktop.
[How-to] Use GitHub Desktop to clone and commit to a Bitbucket repository just as you would with any GitHub repository. (Mac)

⚠️ Note: this guide is from 2016 – a long time on the internet. Content may be outdated, check the comments for more recent info.


Clone Bitbucket Repository and Add it to GitHub Desktop App (Mac)

You can’t clone a Bitbucket repo using GithHub Desktop directly. Instead you would have to:

  1. Clone the Bitbucket repo locally via command line.
  2. 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:

Retrieve git URL from Bitbucket.org

1. Clone Bitbucket Repository Locally via Command Line

  1. Open Terminal app.
  2. 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).
  3. Hit enter. You’ve just opened that parent folder on the command line.
  4. Type git clone https://example@bitbucket.org/path/to/your-repo.git (replacing that sample URL with the Bitbucket URL available on the Overview page of your repository).
  5. Hit enter and watch the repository being cloned. (Once it’s done, it’ll say something like …done in one of the last lines.)

2. Add Cloned Repository to Your GitHub Desktop App

  1. Open GitHub Desktop.

  2. In the upper right corner (if your sidbar is open) press the large + button.

  3. Select Add to add an exisiting local repository.

  4. On the Add tab click the Choose… button, navigate to the folder you have just cloned your Bitbucket repository into, and select it.

    “Add” tab in GitHub Desktop

  5. 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.

@TurtleShroom
Copy link

WHEN IT ASKS ME TO ENTER A PASSWORD AFTER THE "GIT CLONE" COMMAND, IT WON'T LET ME TYPE ANYTHING.

What am I doing wrong?!

@armelsade
Copy link

You are typing something it's just that the command window don't show the caracters.
Enter your password without paying attention to it and press "Enter", it will work.

@ritesh-chakravarti
Copy link

can i use it with Visual Studio & AnkSVN?

@trevorhreed
Copy link

What if immediately after cloning your repo and adding it to Github For Desktop, you try to sync and you get an authentication error? How can I get Github For Desktop to prompt for and cache my password?

@douglascayers
Copy link

GitHub Desktop will naturally try to authenticate to remote origins using your GitHub account.

To authenticate to Bitbucket, or other non-Github remote repositories, include your password in the repository URL.

Example: https://username:password@bitbucket.org/username/repository.git

Note, if your password includes special characters, make sure to url encode your password else you might get fatal: unable to access and Couldn't resolve host errors.

@drewwyatt
Copy link

I'm using SSH (i.e. git@bitbucket.org:team/repo.git), is that possible? I keep getting "Authentication Failed".

@djmcgill
Copy link

@drewwyatt
I have successfully used SSH origins from inside github desktop, by using a ssh credential storer. On OSX I used this method: https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically

@SHADOWELITE7
Copy link

this is very useful

@notasausage
Copy link

notasausage commented Dec 11, 2018

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:

git@bitbucket.org:teamname/repo-name.git

Change the git part to your Bitbucket username:

username@bitbucket.org: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:

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/id_rsa

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.

@notasausage
Copy link

Couple more things:

  • You have to add your machine's SSH key to your BitBucket account (Profile > Settings, SSH Keys) if you haven't already
  • I had to run ssh -T username@bitbucket.org on the command line for a new machine setup to add it to a list of known hosts to actually fetch from GitHub Desktop, even after doing all of the above

@rishabh876
Copy link

My bitbucket account had no password as I use to login via Gmail account. So I generated an App Password from bitbucket and used that password with my username.

https://bitbucket.org/account/user/{username}/app-passwords

@justinTM
Copy link

justinTM commented Dec 4, 2019

Thank you, @rishabh876.

@udemethegrtman
Copy link

@notasausage how can i set it up on windows 8.1 with ssh to aws codecommit.

@mikaeelkhalid
Copy link

My bitbucket account had no password as I use to login via Gmail account. So I generated an App Password from bitbucket and used that password with my username.

https://bitbucket.org/account/user/{username}/app-passwords

Thank you, @rishabh876. This works perfectly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment