function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
john braun 28john braun 28 

Need help with the "App development with Salesforce DX" Module - how do you connect your Salesforce DX project to your VCS (Git)?

Hi all,
I'm on the "App development with Salesforce DX" module, "Get ready to create an app" unit and then the topic, "Metadata Magic: Pull Changes into your Project" but am failing to understand a core concept.

I have created the salesforce dx project for the geolocation app and a scratch org with the salesforce DX CL. I have also created a Git account to use as my version control system.

What I don't understand is how do I actually pull metadata from my scratch org into my Git repository? The directions the trailhead topic give are:
See my note in bold below. 

As a best practice, immediately commit the source you brought into your project to a VCS. Scratch orgs are ephemeral and temporary, so you always want a backup of work you’ve saved locally.
Salesforce DX is version control agnostic, so you can use whatever system you prefer. Here’s an example of the Git commands you can use with GitHub. Use these one-time commands to initialize the repo and connect it to GitHub:

git init
git remote add origin [github ssh url]


***When I try the "git init" command in my windows command prompt - the command prompt tells me that "git" is not recognized as an internal or external command, operable program or batch file***

These commands commit the file to the repo, master:

git add -A
git commit -m “Added custom object and permset”
git push origin master

Whatever VCS you use, we recommend that you configure it to exclude the .sfdx folder from being added to the repository. This folder holds temporary information for your scratch orgs, so you don’t have to save it for posterity in your VCS. In git, you would add it to the .gitignore file.
Now your updated object definition is safe and sound in your VCS. But it isn’t very interesting without any associated data. Scratch orgs come with some standard data based on the edition you choose. However, it’s important to add some sample data that’s more relevant to the app or artifact you’re building. In our example, the new custom Location field could use some sample data. So let’s use the Salesforce CLI to add some for the new compound field.


I am not seeing instructions or a process to which you actually connect your Salesforce DX project to your VCS. Can anyone help me? Thanks!
Barney Lewis 10Barney Lewis 10
John & any others interested, you may be better off waiting to do this until after you have done the Github modules at the end of the trail, especially if you're not familiar with Git. This will step you through the process of creating an account on Github, installing the relevant software and getting you started with your first repository.

Assuming you've done this, or have an existing account and some familiarity, then create a new repository (in this example salesforce-dx), then use the command (replace <<user name>> with your github user account)

git remote add origin https://github.com/<<user name>>/salesforce-dx.git

in place of the suggested command

git remote add origin [github ssh url]

All being well, when you later run the command

git push origin master

You should see some details of the uploaded files like this:

Counting objects: 73, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (68/68), done.
Writing objects: 100% (73/73), 17.51 KiB | 1.95 MiB/s, done.
Total 73 (delta 42), reused 0 (delta 0)
remote: Resolving deltas: 100% (42/42), done.
To https://github.com/<<user name>>/salesforce-dx.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.


Hope that helps - I'm a relative newcomer myself and had to figure this out so apologies if there's anything that doesn't work out for you - I'm running on Windows so YMMV if otherwise...
Ashish KumarAshish Kumar
Hi John,

Barney has nicely explained the steps to upload the project to Github repository.
But to get started with Github, you need to have two things.
1. Github or any other repository account ( which you already have as you said in your post).
2. Git Bash / Github desktop client to connect with github. 
Git Bash is basically a CLI to connect you machine with Github repository. You can install it from here https://git-for-windows.github.io/
After installing it you will be able to run the commands as described in the trailhead modules as well as explained by Barney.

Please let me know if it made you to get started with Git/Github.

Regards,
Ashish Kr.