Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use BitBucket with VS Code?

I am using Bitbucket as my Remote repository. My IDE is VS Code. I am now developing flutter projects.

Can someone please explain me, step by step, how I can push and pull code from VS Code to BitBucket?

I have installed their plugin and all, but I can't figure out how. Every online tutorial, including Atlassian official, seems to be confusing and half baked.

I am on Mac. Git is installed as a part of Flutter installation process.

like image 897
PeakGen Avatar asked Mar 12 '20 15:03

PeakGen


2 Answers

  1. Create a new repository in bitbucket

  2. Clone this in new project in VSC - folder is created automatically You will need to insert the remote repository, something like https://[email protected]/myname/guestbook.git enter image description here

  3. Make changes. Or copy an existing project, but leave the .git directory unchanged!

  4. Commit

  5. push

like image 199
Aris Avatar answered Sep 21 '22 23:09

Aris


I've been wondering the same and spent most of the day trying!!!

I've managed to do part of it in the end. Definitely not the "best practice" approach but might help you get started (if you're on Windows).

First follow the steps here in terms of setting up SSH Keys in VS Code/BitBucket . Definitely a pre-requisite for VS Code to recognize your SSH Keys connected to your BitBucket account

  • From Bitbucket perspective: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html#SetupanSSHkey-ssh3
  • From VS Code perspective: https://www.cgranade.com/blog/2016/06/06/ssh-keys-in-vscode.html

Then, Install the Bitbucket and JIRA Extension:

  • https://marketplace.visualstudio.com/items?itemName=Atlassian.atlascode
    Detailed instructions here on how to set-up
  • https://confluence.atlassian.com/bitbucket/install-atlassian-for-vs-code-969520759.html Once done, do not forget (in VS Code) to login to Bitbucket

Then...

1- Create your empty repro in Bitbucket. Copy both the SSH and HTTPS Clone Git instruction (click on the CLONE button on the right-hand side when you're on the "Source" folder in Bitbucket Cloud).

2- Select the Terminal tab in VS Code (View -> Output/Terminal). Navigate to the directory under which you want to create your repo locally (do not create a folder for your repo that will be creates automatically) and paste your GIT clone instruction => It should work and clone your (empty project). If it fails for some SSH Keys, use the HTPPS Clone instruction.

Milestone 1: At this stage an empty folder with the name of your repo should be created and have the .git subfolder.

From there you can...

1) code away

2) use the "Source Control" menu on the left hand-side of VS code navigation bar to see files pending and commit your changes

I got stuck at the "push" part trying to use the Source Control menus. Kept getting an error about origin.

As I'm really useless with GIT I reverted to SourceTree to push my changes. But at least all the basic qork in VS code and finally get all my code in the repo on BitBucket cloud. I'm sure there is a git command to set the origin using the terminal but don't have patience.

I hope it helps you get started. I had a nightmare with it today!

like image 42
marc Avatar answered Sep 20 '22 23:09

marc