rake_commit_tasks now supports git

The rake_commit_tasks
plugin now has preliminary support for git.
rake_commit_tasks is a
rails plugin which contains a set of rake tasks for checking your
project into source control (git or subversion).

The workflow for committing and pushing with git is slightly different
from subversion. The current steps of “rake commit” with git are

  1. Resets soft back to origin/branch_name (git
    reset—soft origin/branch_name)
  2. Adds new files to git and removes deleted files (git add -A .)
  3. Prompts for a commit message
  4. Commits to git (git commit -m ’…’)
  5. Pulls changes from origin and does a rebase to keep a linear history
    (git pull—rebase)
  6. Runs the default rake task (rake default)
  7. Checks cruisecontrol.rb to see if the build is passing
  8. Pushes the commit to origin (git push origin branch_name)

The “git reset—soft” in #1 is used to collapse unpushed commits. Each
time “rake commit” is run, any commits that have not been pushed are
undone and the changes are put into the index. Then, the “git add -A .”
adds the new changes. Now, the “git commit” command will create one
commit with all of the unpushed changes.

This collapsing comes in handy when “rake commit” fails (for example, a
broken test). Once the test is fixed, the fix should go into the same
commit as the original work. Without the “git reset” command, there will
be two commits (the original, and the one with the fix).

The “—rebase” flag is used in #5 when running “git pull” to keep a
linear history without merge commits. If someone else has committed and
pushed, a normal “git pull” will create a merge commit merging the other
person’s work with your own. The “git pull—rebase” undoes the local
commit, does a “git pull” and then replays the local commit on top.
Merge commits are useful when there are multiple streams of work, such
as a release branch. However, when everyone is working in master, they
merely clutter the history.

Comments and patches are welcome.

Paul Gross

Paul Gross

I'm a lead software developer in Seattle working for Braintree Payments.

Read More