How to use BitBucket with VS Code?
Asked Answered
H

6

15

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.

Hard answered 12/3, 2020 at 15:30 Comment(0)
D
14
  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

Duodiode answered 1/10, 2020 at 12:19 Comment(0)
M
7

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

Then, Install the Bitbucket and JIRA Extension:

Then...

  1. Create your empty repo 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 created automatically) and paste your GIT clone instruction => It should work and clone your (empty project). If it fails for some SSH Keys, use the HTTPS 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 work 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.

Maxia answered 26/4, 2020 at 0:37 Comment(1)
It's the same for me. I can push only from the terminal after starting ssh-agent and adding the private key to it. Remote actions (i.g. push/pull) don't work with VS Code git ui.Tergiversate
S
2

Try following steps,

  1. Create a new repository in bitBucket

  2. Copy, clone URL

  3. Open the VS code and Click "New Window" in the File menu

  4. Click "clone repository" under Start in the Welcome window or in the source control tab

  5. Paste clone URL

  6. Select the location folder (don't create the project folder manually, it will be created automatically)

  7. A window open for authentication

  8. Now you can add new files or copy existing one

  9. In the "Terminal" menu click new terminal

    In the new terminal set following git command

    git config --global user.email "[email protected]"

    git config --global user.name "Your Name"

  10. After changes, commit

  11. Now push

Sigil answered 2/1, 2021 at 9:56 Comment(0)
D
1

If by "using BitBucket" you mean setting up a local repository from an existing BitBucket repo, I found this BitBucket tutorial to be pretty straightforward and self-explanatory. I tried it and was able to clone, edit, commit, push, etc.

You may need to update your user.email and can do so with git config --global user.email "[email protected]".

Danika answered 10/3, 2022 at 8:11 Comment(0)
M
1

Try the following:

  1. Go to your bitbucket branch
  2. Click "Clone" on the left hand side, a small window will pop-up See the image for reference
  3. Clone the "SSH" URL.
  4. Go to your VS Code Start window and click "clone repository", now paste the copied link and select a folder for your repo.
  5. After opening the cloned folder you should be able to access your branches
Mayramays answered 14/2 at 17:51 Comment(0)
N
0

enter image description here

If your git password was required by the source control system,

  1. Sign in to the bitbucket
  2. Go to Personal Setting > ACCESS MANAGEMENT
  3. App passwords > Create app password

When source control asks for a password, you can use the created password as your git password.

Please double-check that you already have these configs.

git config --global user.email "[email protected]"
git config --global user.name "Your Name"
Nopar answered 14/3, 2023 at 4:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.