Here's how I migrated all my "Salesforce configuration metadata backups" from Eclipse to VSCode without my 5-year-old Git
history really caring.
This is a bit of a quick-and-dirty low-quality post; sorry. Publishing it on the blog in case I forgot an org and need it again myself. 😆
Note that this only worked because I didn't need to convert mdapi-style metadata files to sfdx-style metadata files (I didn't have any objects
in src
).
Setting up VSCode to edit Salesforce metadata
Katie ・ Apr 10 '19 ・ 9 min read
- Back up the whole Eclipse folder to some directory far, far away in case I majorly mess up.
- Delete every folder but
src
(which is a sub-folder of the tracking folder) and.git
; stage & commit & push in Git with SourceTree.- Everything else is just stuff that has to do with Eclipse.
- Delete cruft from
src
; stage & commit & push in Git with SourceTree.- If I have
src
things I don't want in my new environment, like artifacts from packages, get rid of them now. - They just get in the way of Git successfully tracking renames in the next step (it has limits of how many file renames it can track at a time).
- If I have
- Rename
src
todefault
.- Then create a new folder
main
at the same level of the filesystem asdefault
; dragdefault
inside ofmain
. - Then create a new folder
force-app
at the same level of the filesystem asmain
; dragmain
inside offorce-app
. - Then stage in Git with SourceTree.
- Then create a new folder
- Hopefully I have a "yay, the renames worked!" moment.
- If so, commit & push in Git with SourceTree.
- If not, troubleshoot (e.g. try staging smaller batches for multiple commits; make sure "rename tolerance" settings are all the way up in my Git installation; etc.).
- In VSCode,
SFDX: Create Project with Manifest
name_it_whatever
(don't use spaces or VSCode will yell at you) inC:\Users\myusername\Documents\Repos\wrapper_folder_name
- Close the folder in VSCode
- In File Explorer, rename
C:\Users\myusername\Documents\Repos\wrapper_folder_name\name_it_whatever\
toC:\Users\myusername\Documents\Repos\wrapper_folder_name\Meaningful Name\
- Open
C:\Users\myusername\Documents\Repos\wrapper_folder_name\Meaningful Name\
in VSCode - Connect this project to the Salesforce org it represents with
SFDX: Authorize an Org
.- No need to actually retrieve any metadata from the server yet (although it certainly might, so maybe set the package.xml minimal?)
- Delete the
C:\Users\myusername\Documents\Repos\wrapper_folder_name\Meaningful Name\force-app
folder - Copy over
force-app
and.git
from the org I've been tearing apart into the new folderC:\Users\myusername\Documents\Repos\wrapper_folder_name\Meaningful Name
. - Rename the old folder so SourceTree can't find it and prompts me for the new folder; choose the new folder.
- If it doesn't prompt, close SourceTree hand-edit
C:\Users\myusername\AppData\Local\Atlassian\SourceTree\bookmarks.xml
. - But I probably just forgot to do the whole "renaming the old folder" bit, honestly.
- SourceTree won't prompt if I just leave it empty of a
.git
sub-folder; it'll merely act up.
- SourceTree won't prompt if I just leave it empty of a
- If it doesn't prompt, close SourceTree hand-edit
- Set up
C:\Users\myusername\Documents\Repos\wrapper_folder_name\Meaningful Name\.gitignore
the way I like it.- e.g. before
#Salesforce cache
add the chunk below these instructions.
- e.g. before
- Test:
- Delete a file; make sure it ends up in Git potential changes.
- Retrieve from package and make sure it comes back onto the filesystem and disappears from Git potential changes.)
- PROFIT.
# Other
.sfdx/orgs/MYUSERNAME@EXAMPLE.COM/metadataTypeInfos.json
.vscode/
.gitignore
config/project-scratch-def.json
sfdx-project.json
.forceignore
.prettierignore
.prettierrc
README.md
Related Reading: Note that the links below ended up being overkill for me, since I didn't have object
folders in src
anyway. Still, I thought it was worth noting their existence -- for example, I learned about setting my Git rename tolerance up higher.