PART 1: Set Up and get an Up-To-Date Org
This tutorial will show you how to pull files from a GitHub, and essentially clone someone’s Salesforce org from a repo.
Step 1: Create a New Trailhead Playground
This will take about 5 minutes to make.
Step 2: Create a New Folder
Wherever you would like to save files locally.
Step 3: Open Git Bash in that folder
Step 4: Find the Repo On GitHub
Go to the branch you want to clone.
Step 5: Copy the Repo URL
Press the Clone or download button.
Step 6: Git Clone [insert URL here]
Now you should have everything from the repo on your local machine
Step 7: Get info from your new Trailhead Playground
Interrogate your playground.
You will need your username, password, and security token. Start by logging into your new Trailhead playground
Setup > Quick Find > Users
Find the user with your name and email address. Copy that username to a safe place. I like to keep a Notepad++ window open.
Next to your user account, check the checkbox and click the “Reset Passwords” button. You will get an email with a link to reset your password. Do that and save your password in a safe spot.
If you are in Salesforce classic, click on your name on the top right, then click on “My Settings”
In the Quick Find box, type “Token” and click on “Reset My Security Token”.
Reset your token. You will get an email with your new token. Save that token in a safe spot.
Step 8: Set Up Eclipse Workspace
Open Eclipse, and set your workspace to the folder you created earlier to clone the repo into.
Step 9: Create a New Branch to Work in
In Git Bash, you might need to cd into the repo folder, so do that if necessary.
Once you are on the cloned branch, make a new branch and switch to it.
git checkout -b NameOfNewBranch
You should now be on your new branch.
Step 10: Create a new Force.com Project
and connect it to your Trailhead playground.
File > New > Other > Force.com > Force.com Project
Make sure the project name is the same as the repo folder name, for me, the project name is ExamForce.
Input the username, password, and token that you saved earlier.
Choose “None” for Initial Project Components
After loading up, you should see which branch you are working on. You should also be able to see all the components of your project that you cloned from GitHub
Step 11: Edit Package.xml
Make it 41 instead of 38
Step 12: Synchronize
I’m syncing everything in the “src” folder.
In the Synchronize view, Apply Project to Server to push all your files from github up into your playground.
Step 13: Check Deployment Details
In your org, go to setup > Quick Find > Deployment Status
Step 14: Debug Deployment Errors
In this case, we can remove a couple lines from our package.xml and those errors will go away. We don’t actually use those features in our app. I’m not sure why they are in the repository, but this happens all the time with this development stack unfortunately. With time, you get better at recognizing and debugging deployment errors. Remember that Google is your friend.
Step 15: Verify that your Org is up to date
Click around in your org and make sure the right things are in there.
PART 2: Make a Change In Your Org and Push It to GitHub
Step 1: Edit Things on Salesforce
We are going to change a line in ExamForceHome.vfp and correct it. Right now it says style=”” when it should say class=””.
Now that we have saved that change in our org, let’s pull it down from the cloud into our local git repository using the Force.com IDE. How fun!
Step 2: Pull in the needed files using Force.com IDE
Navigate to the file(s) in Force.com IDE, and select “Refresh from Server”
You should now be able to see your updated file in eclipse.
Step 3: Add Your Changes
Let’s navigate to the file and use git add.
Step 4: Commit Your Changes
Now you must be committed. COMMIT!
Step 5: Push Your Changes
Now you must PUSH. PUSH!!!!
Step 6: Submit a Pull Request
Go to your branch on github.com
As you can see, our new branch is on GitHub
Click on the “New pull request” button.
That’s it for this tutorial.