1

I'm using VS Code, Bitbucket, and a standard sandbox (not scratch org).  What's the correct procedure to clone an existing repository and connect it to the sandbox?

I've read this question/answer but it doesn't work for me.

I've tried the following:

1.  If I clone the repo and then open the workspace in VS Code, I don't get the Authorize an Org command on the palette, even after waiting.  Authorizing by CLI doesn't do anything -- I still don't get the SFDX retrieve command when I right-click on the package.xml file.

2.  If I create a new project with manifest, then the right-click commands appear for package.xml, but I can't clone into the workspace because git won't clone into an existing folder.

I've searched around but haven't found a clear answer. Is it possible that I'm missing some VSCode config files in the repo?

EDIT: Here's some background detail.  I had created this repo using VS Code just a few days ago.  First I created a new project with manifest, retrieved some metadata, and then created the repo and pushed the files.  Everything looked OK.  I didn't do any other activity in VS Code or the repo except for this initial commit. I did omit some .json files which looked like VS Code config files -- I may have accidentally removed them from my local folder.

This morning in VS Code I've lost the right-click SFDX commands on package.xml and the Authorize an Org command doesn't appear on the palette.  I tried a few things (including restoring the .json files), then deleted the whole workspace folder and cloned the repo, and now I'm stuck with the issues above.

4
  • Can you create a "blank" bitbucket repo you can share? I'd be glad to try and troubleshoot this. P.S. I've done this tons of times for various reasons, I've never had an issue, so maybe it's a project configuration issue or something. – sfdcfox Mar 10 at 18:27
  • @sfdcfox Thanks for the offer, I'll see if I can create one. Also I added some more detail to my post. – David Cheng Mar 10 at 18:47
  • @sfdcfox Here's my public repo. I tried clone it and opening the workspace in VS Code and I get the same issue. bitbucket.org/idealistconsulting/aatest/src/master – David Cheng Mar 10 at 20:10
  • Great. I love a good repro. Let me see what I can do. Hang tight. – sfdcfox Mar 10 at 20:41
1

Your project is missing a bunch of critical files. Fortunately, this is super-easy to fix. Starting from the cloned folder, go up a directory, then run the project creation script. If this is a fresh clone (as in this demo), you don't need to cd before running the creation script. Make sure that -n matches the repo name, as you want to force overwrites of files already present.

brian@LAPTOP-1G9C6IIH MINGW64 ~/scratch
$ git clone https://bitbucket.org/idealistconsulting/aatest.git
Cloning into 'aatest'...
remote: Counting objects: 16, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 16 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (16/16), done.
    
brian@LAPTOP-1G9C6IIH MINGW64 ~/scratch
$ sfdx force:project:create -n aatest
target dir = C:\Users\brian\scratch
   create aatest\config\project-scratch-def.json
 conflict aatest\README.md
    force aatest\README.md
   create aatest\sfdx-project.json
   create aatest\.vscode\extensions.json
   create aatest\.vscode\launch.json
   create aatest\.vscode\settings.json
   create aatest\force-app\main\default\lwc\.eslintrc.json
   create aatest\force-app\main\default\aura\.eslintrc.json
   create aatest\scripts\soql\account.soql
   create aatest\scripts\apex\hello.apex
   create aatest\.eslintignore
   create aatest\.forceignore
 conflict aatest\.gitignore
    force aatest\.gitignore
   create aatest\.prettierignore
   create aatest\.prettierrc
   create aatest\package.json

After that, open code:

brian@LAPTOP-1G9C6IIH MINGW64 ~/scratch
$ code aatest/

You may be prompted to "install recommended extensions." If asked, you should do so.

After this, you should have your authorization menu options (and everything else you're missing).

Make sure you commit any changes you want to save, or you can revert some of the files (like .gitignore or README.md) if you've got some files you'd like to preserve.

2
  • It works, thanks so much! What's the best practice regarding these files -- should be they included in the repo? Or omit them and always run the sfdx create script after cloning? – David Cheng Mar 10 at 22:33
  • @DavidCheng Most of the files are technically optional depending on what tools you want to use while developing, but I'd strongly recommend just committing all of these files, except perhaps the scripts folder, which is there only for demonstration purposes. – sfdcfox Mar 10 at 22:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.