Search code examples
mysqlgitmigrationgit-branchtopological-sort

Imposing a Partial Ordering on Git Commit IDs


I'm converting the infrastructure at my workplace to use git instead of svn. The overall migration is going well, but we have a tool that I developed to do our SQL schema migrations.

In order to deal with individual schema change dependencies, the migrations script used subversion keyword replacement to put the last-changed revision number in the schema. With git, we can't use the same idea, since revision history is non-linear (and we're fully intending on utilizing the branching features).

Therefore, how do I get a topologically sorted list of commit ids out of git? Barring that, anyone have a better idea for how to handle this problem?


Solution

  • git rev-list old-revision..new-revision
    

    That shows newest-first. If you want oldest-first, add --reverse