There is quite a big difference between what your stated goal is and what the command you're planning to use does. In order to get the commits, all you need to run is git fetch
. You can use system
or backticks in order to run shell commands from your ruby code, but you need to be careful about what you run. You should keep in mind that a pull is a merge, which means that at any time changes could conflict and it would leave your repository waiting for human intervention (not to mention files with conflict markers all over them) as it's part of the high-level user interface, and not meant at all to be scripted.
If you do want the version of the files in the tip, to do deployment or similar, you can check out http://gitolite.com/the-list-and-irc/deploy.html for some different ways to do that, depending on the situation.
You can use a combination of shelling out to git fetch
and git checkout
or rugged in your code to perform this update, and be aware that this is all IO-bound (part of it over the network) which means that it can take an arbitrary amount of time to run, which may not work too well with the rest of your app if it's blocking ruby's execution.