Git Your Force.com - Part2
Config Your Develpment Environment
Git is working on the local, so if you want to use the git in your force.com project, you need to move your IDE from cloud to local. For now, I think the MavenMate is the best choice.
- Install git and config it
- Install MavensMate
- Create a new account in Meginfo Gitlab server and upload your SSH public key
Use the Git In Your Project
Start New Project
If you want to use the git in you new project, please use the following setps to initialize it.
- Create a new Force.com project by MavensMate in Sublime
- Open the project and use git to init it
- Create a new file
.gitignore
below the root of your project and put the following content into it1 2 3 4 5 6
config/ *.sublime-project *.sublime-workspace *.log deploy/ src/staticresources/
If you want to check the
static resources
, pelase remeber to remove the end line. - Add and commit all the code by git
- Log in the Gitlab and create a new project
- Link the remote repository with your local repos and push your code to the remote service
1
2
3
$ cd existing_git_repo
$ git remote add origin git@scm.meginfo.com:xxxx/xxxx.git
$ git push -u origin master
Work on a Existing Project
If you are new member in a team that is using git and Gitlab as a workflow. You need to do these steps to jion the team to code with them.
- Get the git remote link in Gitlab
- Clone the project from Gitlab into your MavensMate workspace
-
Create the project as a MavesMate project, so you can save your code to the Force.com platform
- Open the project folder via Sublime
- Click the right mouse on project name in Sublime sidebar, go to
MavensMate -> Create a new project
- Fill out the login credential that you want to work in the force.com org
- Create a new branch or checkout a existing remote branch
- Coding follow with our workflow
Our Workflow
We use the GitHub Flow which is a lightweight, branch-based workflow in our projects.
There’s only one rule: Anything in the master branch is always deployable.
- Create a branch right from the repository
- Develop and commit in the feature branch
- Open a merge request from your branch with your changes to kick off a discussion
- Others review your code and testing
- Merge the feature branch into master branch
- Update the change status and bump a tag with change number, such as
c-31502
- Delete the feature branch and deploy your code
ProTip
- Your branch name should be descriptive (e.g.,
refactor-authentication
,make-retina-avatars
), so that others can see what is being worked on. - You can also continue to push to your branch after opening a merge request. If someone comments that you forgot to do something or if there is a bug in the code, you can fix it in your branch and push up the change
- Commit messages is important, please check here how to write a good commit message