You need to create some files to make a directory into a SFDX project, particularly sfdx-project.json
. The easy way to do this is to go to the parent folder of your Git root, and type in the command sfdx force:project:create -n directoryName
. This creates a number of files from a template that will be used to configure the project. After this, you should then convert your source folder using the steps below.
That looks like this:
computer-name MINGW64 ~/workspace/my-git-project (master)
$ cd ..
computer-name MINGW64 ~/workspace
$ sfdx force:project:create -n my-git-project
target dir = C:\Users\my-name\workspace
create my-git-project\config\project-scratch-def.json
create my-git-project\README.md
create my-git-project\sfdx-project.json
create my-git-project\.vscode\extensions.json
create my-git-project\.vscode\launch.json
create my-git-project\.vscode\settings.json
create my-git-project\force-app\main\default\lwc\.eslintrc.json
create my-git-project\force-app\main\default\aura\.eslintrc.json
create my-git-project\scripts\soql\account.soql
create my-git-project\scripts\apex\hello.apex
create my-git-project\.eslintignore
create my-git-project\.forceignore
create my-git-project\.gitignore
create my-git-project\.prettierignore
create my-git-project\.prettierrc
create my-git-project\package.json
You may also see "conflict" and "force"; this means files were overwritten. You can git checkout
to revert those changes afterwards.
Git is good about detecting the file name changes. However, it has a built-in limit on a number of files it can handle at a time.
Hence when you convert your project to sfdx format chances of losing history are high since number of files that get renamed in this process may be higher than the limit that git has.
You can increase this limit by a simple config like below
git config merge.renameLimit 999999
Here is what you will need to preserve the history
git config merge.renameLimit 999999
sfdx force:mdapi:convert -r src -d tmp // This converts what is in src to a DX source format and moves to tmp folder
rm -rf src // This removes src folder
mv tmp src // This moves tmp folder items to the src folder
git add -A
git commit -m "Converted from metadata to source format"
git config --unset merge.renameLimit # Return the git config option to the default