How can I automate the process or retrieving a snapshot of my code and configuration and committing it to git?

We have a ton of development happening in my org, and I'm currently saving daily snapshots in git, to keep a handle on our expanding configuration and code.

I'm currently using Ant and EGit, both from within Eclipse. A downside is that I have to manually run the ANT retrieve macro and then commit to git each day. I'd love to automate this process, but I'm not sure how to.

  • What don't you know how to do? Just use the command-line versions of both, which have tons of documentation.
    – jkraybill
    Dec 19, 2012 at 3:06
  • @jkraybill Are the command-line versions included in Eclipse, or would I have to install and configure them separately? If they're included in Eclipse, how can I find/access them?
    – Benj
    Dec 19, 2012 at 13:53
  • Install is at Setup > Develop > Tools for Force.com Migration Tool; docs at wiki.developerforce.com/page/Migration_Tool_Guide; for git, google is your friend.
    – jkraybill
    Dec 20, 2012 at 4:12
  • @jkraybill I know how to install the tools themselves (I'm already using them). The question is, how do I get to the command-line versions?
    – Benj
    Dec 24, 2012 at 14:52
  • The Force.com Migration Tool is only a command-line interface (via Ant), so you'll get it if you follow the link to install and read the docs. For git, search git command line (your operating system) to get your command line client of choice. The Migration Tool is invoked via "ant deploy" and similar commands from a command line; git is invoked via "git clone", "git commit" etc from a command line.
    – jkraybill
    Dec 28, 2012 at 0:25

1 Answer 1


If you can use the command-line versions of these tools, then you could wrap all of this up with a script and set it to run on a schedule (cron or other). I didn't test this, but this would be a bash (OSX, Linux, Unix) version of what you could do...


# clear out existing code
# this is important to capture deletes
rm -rf src/*

# run ant
ant retrieve

# do a git snapshot
git add .
git commit -m "daily snapshot"
git push
  • Finally got around to doing it - this was perfect, and is now set up in a cron job
    – Benj
    Jan 21, 2013 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.