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
- Resets soft back to origin/branch_name (git
- Adds new files to git and removes deleted files (git add -A .)
- Prompts for a commit message
- Commits to git (git commit -m ’…’)
- Pulls changes from origin and does a rebase to keep a linear history
- Runs the default rake task (rake default)
- Checks cruisecontrol.rb to see if the build is passing
- 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.